3 ms·
I also want to remove CROW_ROUTE, but with the current c++ standard, it cannot be avoided. To check whether handler is valid with given URL at compile time, `u
by ipkn 12y ago
I also want to remove CROW_ROUTE, but with the current c++ standard, it cannot be avoided.
To check whether handler is valid with given URL at compile time, `url' (string literal) argument requires in compile time and in run time. const char* value is invalid for template argument and argument of non-constexpr function cannot be constexpr value. Thus I used macro to provied `url' argument twice; in template argument through constexpr function and in argument.
- pmr_ 12y agoYou can still do metaprogramming on single character constants and with a bunch of really ugly hackery make it somewhat pretty. You might be interested in metaparse [1] which can greatly simplify compile time parsing of strings but has a very steep learning curve. [1]: http://abel.web.elte.hu/mpllibs/metaparse/ http://abel.web.elte.hu/mpllibs/metaparse/
- ipkn 12y agoI already considered using a template with single character constants, and I thought the technic didn't have much benefit over the macro version. Maybe compile-time routing function genetation could be possible with it (and would faster), but requres HUGE work I think. I will try and benchmark it later.
- mtdewcmu 12y agoI'd hope that in the end, the efficiency of the routing matters more than templates vs macros. You will never finish anything if you pay too much attention to all the purists. Useful strings at compile time is a desirable feature beyond c++, though. A perfect hash could be a nice solution, I thought, but I got around to trying out gperf, and it was much slower than I expected. Probably too slow to use in ordinary situations. I guess gperf is for when (runtime) performance is incredibly important. Another possible approach to strings at compile time is something like flex, or re2c. I haven't tested them in this type of scenario. But, apparently Zed Shaw used ragel to parse http in Mongrel to excellent effect. My problem with ragel is its complicated syntax.