Compile-time string comparing
Hi all. I think it's frequently asked question. If so, I'm sorry. Is there anything feature in Boost that allows to compare strings at compile-time? I know that it is easy-implemented with generalized constant expressions, but I'm primarily interested in compatibility of compilers. Thanks.
2014-04-11 16:15 GMT+04:00 Anton Bikineev
Hi all.
I think it's frequently asked question. If so, I'm sorry.
Is there anything feature in Boost that allows to compare strings at compile-time?
You can try to use MPL's string:
http://www.boost.org/doc/libs/1_55_0/libs/mpl/doc/refmanual/string.html
typedef mpl::string<'hell','o wo','rld'> hello;
typedef mpl::string<'hi t','here'> hi;
BOOST_STATIC_ASSERT(!boost::is_same
Antony Polukhin
You can try to use MPL's string: http://www.boost.org/doc/libs/1_55_0/libs/mpl/doc/refmanual/string.html
typedef mpl::string<'hell','o wo','rld'> hello; typedef mpl::string<'hi t','here'> hi; BOOST_STATIC_ASSERT(!boost::is_same
::value);
Thank you, Antony. Just thought about mpl::string, but forgot about type traits. :)
On 4/11/2014 5:31 AM, Antony Polukhin wrote:
2014-04-11 16:15 GMT+04:00 Anton Bikineev
: Hi all.
I think it's frequently asked question. If so, I'm sorry.
Is there anything feature in Boost that allows to compare strings at compile-time?
You can try to use MPL's string: http://www.boost.org/doc/libs/1_55_0/libs/mpl/doc/refmanual/string.html
typedef mpl::string<'hell','o wo','rld'> hello; typedef mpl::string<'hi t','here'> hi; BOOST_STATIC_ASSERT(!boost::is_same
::value);
You don't want to use boost::is_same for this. It only compares the type
of the container, not the elements of the sequence. (Consider that
mpl::vector
participants (3)
-
Anton Bikineev
-
Antony Polukhin
-
Eric Niebler