Merge pull request #287 from nx10/gcc8-workaround

GCC 8.3 workaround
This commit is contained in:
Farook Al-Sammarraie 2021-12-04 14:54:19 +03:00 committed by GitHub
commit 120e1f3ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -79,12 +79,16 @@ namespace crow
return router_.new_rule_dynamic(std::move(rule));
}
/// Create a route using a rule (**Use CROW_ROUTE instead**)
///Create a route using a rule (**Use CROW_ROUTE instead**)
template<uint64_t Tag>
auto route(std::string&& rule)
#ifdef CROW_CAN_USE_CPP17
-> typename std::invoke_result<decltype(&Router::new_rule_tagged<Tag>), Router, std::string&&>::type
#ifdef CROW_GCC83_WORKAROUND
auto& route(std::string&& rule)
#else
auto route(std::string&& rule)
#endif
#if defined CROW_CAN_USE_CPP17 && !defined CROW_GCC83_WORKAROUND
-> typename std::invoke_result<decltype(&Router::new_rule_tagged<Tag>), Router, std::string&&>::type
#elif !defined CROW_GCC83_WORKAROUND
-> typename std::result_of<decltype (&Router::new_rule_tagged<Tag>)(Router, std::string&&)>::type
#endif
{

View File

@ -57,3 +57,11 @@
#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