Boost logo

Boost :

Subject: Re: [boost] Compile-time string comparing
From: Eric Niebler (eniebler_at_[hidden])
Date: 2014-04-11 11:27:01

On 4/11/2014 5:31 AM, Antony Polukhin wrote:
> 2014-04-11 16:15 GMT+04:00 Anton Bikineev <ant.bikineev_at_[hidden]>:
>> 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:
> typedef mpl::string<'hell','o wo','rld'> hello;
> typedef mpl::string<'hi t','here'> hi;
> BOOST_STATIC_ASSERT(!boost::is_same<hello, hi>::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<int, short> and mpl::vector2<int, short> are different types
but have the same elements.)

Use boost::mpl::equal.


Boost list run by bdawes at, gregod at, cpdaniel at, john at