我在项目中使用此CROW项目header file
crow_all.h:9382:86: error: no matching function for call to ‘crow::Crow<>::route(const char [20])’
#define CROW_ROUTE(app, url) app.route<crow::black_magic::get_parameter_tag(url)>(url)
^
main.cpp:20:5: note: in expansion of macro ‘CROW_ROUTE’
CROW_ROUTE(app,"/welcome/<uint64_t>")
^
crow_all.h:9382:86: note: candidate is:
#define CROW_ROUTE(app, url) app.route<crow::black_magic::get_parameter_tag(url)>(url)
^
main.cpp:20:5: note: in expansion of macro ‘CROW_ROUTE’
CROW_ROUTE(app,"/welcome/<uint64_t>")
^
In file included from main.cpp:1:0:
crow_all.h:9423:14: note: template<long unsigned int Tag> typename std::result_of<decltype (& crow::Router:: new_rule_tagged<Tag>)(crow::Router, std::basic_string<char>&&)>::type crow::Crow<Middlewares>::route(std::string&&) [with long unsigned int Tag = Tag; Middlewares = {}]
auto route(std::string&& rule)
^
crow_all.h:9423:14: note: template argument deduction/substitution failed:
In file included from main.cpp:1:0:
main.cpp:20:5: in constexpr expansion of ‘crow::black_magic::get_parameter_tag(crow::black_magic::const_str((*"/welcome/<uint64_t>")), 0u)’
crow_all.h:5866:41: in constexpr expansion of ‘crow::black_magic::get_parameter_tag(s, (p + 1u))’
crow_all.h:5866:41: in constexpr expansion of ‘crow::black_magic::get_parameter_tag(s, (p + 1u))’
crow_all.h:5866:41: in constexpr expansion of ‘crow::black_magic::get_parameter_tag(s, (p + 1u))’
crow_all.h:5866:41: in constexpr expansion of ‘crow::black_magic::get_parameter_tag(s, (p + 1u))’
crow_all.h:5866:41: in constexpr expansion of ‘crow::black_magic::get_parameter_tag(s, (p + 1u))’
crow_all.h:5866:41: in constexpr expansion of ‘crow::black_magic::get_parameter_tag(s, (p + 1u))’
crow_all.h:5866:41: in constexpr expansion of ‘crow::black_magic::get_parameter_tag(s, (p + 1u))’
crow_all.h:5866:41: in constexpr expansion of ‘crow::black_magic::get_parameter_tag(s, (p + 1u))’
crow_all.h:5866:41: in constexpr expansion of ‘crow::black_magic::get_parameter_tag(s, (p + 1u))’
crow_all.h:5864:70: error: expression ‘<throw-expression>’ is not a constant-expression
throw std::runtime_error("invalid parameter type")
^
In file included from main.cpp:1:0:
crow_all.h:9382:86: note: in template argument for type ‘long unsigned int’
#define CROW_ROUTE(app, url) app.route<crow::black_magic::get_parameter_tag(url)>(url)
^
main.cpp:20:5: note: in expansion of macro ‘CROW_ROUTE’
CROW_ROUTE(app,"/welcome/<uint64_t>")
)
下面的代码可以正常使用int
类型,但不适用于uint64_t
。我收录了#include <cstdint>
和#include<cinttypes>
CROW_ROUTE(app,"/welcome/<T>")
([](int count) {
if (count > 400)
return crow::response(400);
std::ostringstream os;
os << count << " Bottles of beer, Cheers...!!";
return crow::response(os.str());
});
// CROW_ROUTE定义如下。
#define CROW_ROUTE(app, url) app.route<crow::black_magic::get_parameter_tag(url)>(url)