diff --git a/ext/crow/routing.h b/ext/crow/routing.h index 52ff77b..ed84334 100755 --- a/ext/crow/routing.h +++ b/ext/crow/routing.h @@ -156,7 +156,7 @@ namespace crow struct Wrapped { template - void set(Func f, typename std::enable_if< + void set2(Func f, typename std::enable_if< !std::is_same>::type, const request&>::value , int>::type = 0) { @@ -190,7 +190,7 @@ namespace crow }; template - void set(Func f, typename std::enable_if< + void set2(Func f, typename std::enable_if< std::is_same>::type, const request&>::value && !std::is_same>::type, response&>::value , int>::type = 0) @@ -205,7 +205,7 @@ namespace crow } template - void set(Func f, typename std::enable_if< + void set2(Func f, typename std::enable_if< std::is_same>::type, const request&>::value && std::is_same>::type, response&>::value , int>::type = 0) @@ -389,32 +389,30 @@ namespace crow // enable_if Arg1 == request && Arg2 == response // enable_if Arg1 == request && Arg2 != resposne // enable_if Arg1 != request -//#ifdef CROW_MSVC_WORKAROUND -// template -//#else -// template -//#endif -// std::function -// wrap(Func f, black_magic::seq) -// { -//#ifdef CROW_MSVC_WORKAROUND -// using function_t = utility::function_traits; -//#else -// using function_t = utility::function_traits; -//#endif -// if (!black_magic::is_parameter_tag_compatible( -// black_magic::get_parameter_tag_runtime(rule_.c_str()), -// black_magic::compute_parameter_tag_from_args_list< -// typename function_t::template arg...>::value)) -// { -// throw std::runtime_error("route_dynamic: Handler type is mismatched with URL parameters: " + rule_); -// } -// auto ret = detail::routing_handler_call_helper::Wrapped...>(); -// ret.template set< -// typename function_t::template arg... -// >(std::move(f)); -// return ret; -// } +#ifdef CROW_MSVC_WORKAROUND + template +#else + template +#endif + std::function + wrap(Func f, black_magic::seq) + { +#ifdef CROW_MSVC_WORKAROUND + using function_t = utility::function_traits; +#else + using function_t = utility::function_traits; +#endif + if (!black_magic::is_parameter_tag_compatible( + black_magic::get_parameter_tag_runtime(rule_.c_str()), + black_magic::compute_parameter_tag_from_args_list< + typename function_t::template arg...>::value)) + { + throw std::runtime_error("route_dynamic: Handler type is mismatched with URL parameters: " + rule_); + } + auto ret = detail::routing_handler_call_helper::Wrapped...>(); + ret.template set2...>(std::move(f)); + return ret; + } template void operator()(std::string name, Func&& f)