2015-06-04 13:52 GMT+08:00 Abel Sinkovics
Hi Evgeny
On 2015-06-03 23:32, Evgeny Panasyuk wrote:
03.06.2015 23:45, Abel Sinkovics:
JFYI, I made small test some time ago with "formatting" stuff at compile-time (ad-hoc parsing, without Metaparse). https://github.com/panaseleus/ctte
Very interesting. Not just the way you generate code, but also the way you pass string literals to metafunctions. Your variadic template + std::make_index_sequence trick seems to be able to replace the macro magic for compile-time string construction. It looks like BOOST_<whatever we end up with>_STRING could be improved with that (I'll have to check).
Note that you should be able to "store" the length of the string in what CTTE_WRAP_STRING constructs (you can get the length with sizeof or with "pattern matching" on the char array length) and then you can also deal with the corner case when a string literal contains \0 characters.
It seems to use the similar trick that I posted in an older thread (you'd been there too): http://boost.2283326.n4.nabble.com/Compile-Time-String-in-C-14-tp4666747p466... We all know that it can't replace your STRING implementation since it cannot be used in unevaluated context. Here's a demo of toy compile-time parser that mimics Boost.Spirit: http://coliru.stacked-crooked.com/a/b5c0d0afd8255b81