diff --git a/include/crow/app.h b/include/crow/app.h index 25592da69..fbf53a075 100644 --- a/include/crow/app.h +++ b/include/crow/app.h @@ -254,16 +254,8 @@ namespace crow /// \brief Create a route using a rule (**Use CROW_ROUTE instead**) template -#ifdef CROW_GCC83_WORKAROUND - auto& route(const std::string& rule) -#else auto route(const std::string& rule) -#endif -#if defined CROW_CAN_USE_CPP17 && !defined CROW_GCC83_WORKAROUND -> typename std::invoke_result), Router, const std::string&>::type -#elif !defined CROW_GCC83_WORKAROUND - -> typename std::result_of)(Router, const std::string&)>::type -#endif { return router_.new_rule_tagged(rule); } diff --git a/include/crow/middlewares/session.h b/include/crow/middlewares/session.h index 66fe4c412..211faae72 100644 --- a/include/crow/middlewares/session.h +++ b/include/crow/middlewares/session.h @@ -23,9 +23,7 @@ #include #include -#ifdef CROW_CAN_USE_CPP17 #include -#endif namespace { @@ -53,7 +51,6 @@ namespace crow namespace session { -#ifdef CROW_CAN_USE_CPP17 using multi_value_types = black_magic::S; /// A multi_value is a safe variant wrapper with json conversion support @@ -118,38 +115,6 @@ namespace crow default: return multi_value{false}; } } -#else - // Fallback for C++11/14 that uses a raw json::wvalue internally. - // This implementation consumes significantly more memory - // than the variant-based version - struct multi_value - { - json::wvalue json() const { return v_; } - - static multi_value from_json(const json::rvalue&); - - std::string string() const { return v_.dump(); } - - template> - RT get(const T& fallback) - { - return json::wvalue_reader{v_}.get((const RT&)(fallback)); - } - - template> - void set(T val) - { - v_ = RT(std::move(val)); - } - - json::wvalue v_; - }; - - inline multi_value multi_value::from_json(const json::rvalue& rv) - { - return {rv}; - } -#endif /// Expiration tracker keeps track of soonest-to-expire keys struct ExpirationTracker @@ -226,13 +191,8 @@ namespace crow template struct SessionMiddleware { -#ifdef CROW_CAN_USE_CPP17 using lock = std::scoped_lock; using rc_lock = std::scoped_lock; -#else - using lock = std::lock_guard; - using rc_lock = std::lock_guard; -#endif struct context { diff --git a/include/crow/routing.h b/include/crow/routing.h index 18bd7cf2b..26690a50a 100644 --- a/include/crow/routing.h +++ b/include/crow/routing.h @@ -248,16 +248,10 @@ namespace crow // NOTE: Already documented in "crow/app.h" template void set_(Func f, typename std::enable_if>::type, const request&>::value, int>::type = 0) { - handler_ = ( -#ifdef CROW_CAN_USE_CPP14 - [f = std::move(f)] -#else - [f] -#endif - (const request&, response& res, Args... args) { - res = response(f(args...)); - res.end(); - }); + handler_ = ([f = std::move(f)](const request&, response& res, Args... args) { + res = response(f(args...)); + res.end(); + }); } template @@ -354,16 +348,10 @@ namespace crow // NOTE: Already documented in "crow/app.h" static_assert(!std::is_same::value, "Handler function cannot have void return type; valid return types: string, int, crow::response, crow::returnable"); - handler_ = ( -#ifdef CROW_CAN_USE_CPP14 - [f = std::move(f)] -#else - [f] -#endif - (const request&, response& res) { - res = response(f()); - res.end(); - }); + handler_ = ([f = std::move(f)](const request&, response& res) { + res = response(f()); + res.end(); + }); } template @@ -376,16 +364,10 @@ namespace crow // NOTE: Already documented in "crow/app.h" static_assert(!std::is_same()))>::value, "Handler function cannot have void return type; valid return types: string, int, crow::response, crow::returnable"); - handler_ = ( -#ifdef CROW_CAN_USE_CPP14 - [f = std::move(f)] -#else - [f] -#endif - (const crow::request& req, crow::response& res) { - res = response(f(req)); - res.end(); - }); + handler_ = ([f = std::move(f)](const request& req, response& res) { + res = response(f(req)); + res.end(); + }); } template @@ -398,15 +380,9 @@ namespace crow // NOTE: Already documented in "crow/app.h" { static_assert(std::is_same()))>::value, "Handler function with response argument should have void return type"); - handler_ = ( -#ifdef CROW_CAN_USE_CPP14 - [f = std::move(f)] -#else - [f] -#endif - (const crow::request&, crow::response& res) { - f(res); - }); + handler_ = ([f = std::move(f)](const request&, response& res) { + f(res); + }); } template @@ -681,15 +657,9 @@ namespace crow // NOTE: Already documented in "crow/app.h" template void operator()(Func&& f) { - handler_ = ( -#ifdef CROW_CAN_USE_CPP14 - [f = std::move(f)] -#else - [f] -#endif - (crow::request& req, crow::response& res, Args... args) { - detail::wrapped_handler_call(req, res, f, std::forward(args)...); - }); + handler_ = ([f = std::move(f)](request& req, response& res, Args... args) { + detail::wrapped_handler_call(req, res, f, std::forward(args)...); + }); } template diff --git a/include/crow/settings.h b/include/crow/settings.h index 4007e67ba..64b17ae45 100644 --- a/include/crow/settings.h +++ b/include/crow/settings.h @@ -33,22 +33,6 @@ #endif // compiler flags -#if defined(_MSVC_LANG) && _MSVC_LANG >= 201402L -#define CROW_CAN_USE_CPP14 -#endif -#if __cplusplus >= 201402L -#define CROW_CAN_USE_CPP14 -#endif - -#if defined(_MSVC_LANG) && _MSVC_LANG >= 201703L -#define CROW_CAN_USE_CPP17 -#endif -#if __cplusplus >= 201703L -#define CROW_CAN_USE_CPP17 -#if defined(__GNUC__) && __GNUC__ < 8 -#define CROW_FILESYSTEM_IS_EXPERIMENTAL -#endif -#endif #if defined(_MSC_VER) #if _MSC_VER < 1900 @@ -57,11 +41,3 @@ #define noexcept throw() #endif #endif - -#if defined(__GNUC__) && __GNUC__ == 8 && __GNUC_MINOR__ < 4 -#if __cplusplus > 201103L -#define CROW_GCC83_WORKAROUND -#else -#error "GCC 8.1 - 8.3 has a bug that prevents Crow from compiling with C++11. Please update GCC to > 8.3 or use C++ > 11." -#endif -#endif diff --git a/include/crow/utility.h b/include/crow/utility.h index bd10874df..b9b963859 100644 --- a/include/crow/utility.h +++ b/include/crow/utility.h @@ -16,9 +16,7 @@ #include "crow/settings.h" -#if defined(CROW_CAN_USE_CPP17) && !defined(CROW_FILESYSTEM_IS_EXPERIMENTAL) #include -#endif // TODO(EDev): Adding C++20's [[likely]] and [[unlikely]] attributes might be useful #if defined(__GNUG__) || defined(__clang__) @@ -291,21 +289,12 @@ namespace crow }; // Extract element from forward tuple or get default -#ifdef CROW_CAN_USE_CPP14 template typename std::enable_if::value, typename std::decay::type&&>::type tuple_extract(Tup& tup) { return std::move(std::get(tup)); } -#else - template - typename std::enable_if::value, T&&>::type - tuple_extract(Tup& tup) - { - return std::move(std::get::value>(tup)); - } -#endif template typename std::enable_if::value, T>::type @@ -812,14 +801,7 @@ namespace crow inline static std::string join_path(std::string path, const std::string& fname) { -#if defined(CROW_CAN_USE_CPP17) && !defined(CROW_FILESYSTEM_IS_EXPERIMENTAL) return (std::filesystem::path(path) / fname).string(); -#else - if (!(path.back() == '/' || path.back() == '\\')) - path += '/'; - path += fname; - return path; -#endif } /**