Boost logo

Boost :

Subject: Re: [boost] [metaparse] performance comparisons?
From: Evgeny Panasyuk (evgeny.panasyuk_at_[hidden])
Date: 2015-06-07 05:41:49


07.06.2015 12:07, Roland Bock пишет:

> However, this is limited in the way that the type cannot be based on a
> literal outside a struct/class. There also is a macro that can be
> employed to create such types, e.g:
>
> SQLPP_ALIAS_PROVIDER(hello);
>
> static_assert(
> std::is_same<hello_t::_alias_t,
> sqlpp::char_sequence<'h', 'e', 'l', 'l', 'o',
> '\000'>>::value,
> "");
>
>
> The MACRO cannot be called in a function, though, since local classes
> must not have static members.

Following code works OK:

int main()
{
     struct specific_compiletime_string
     {
         static constexpr const char *value()
         {
             return "abc";
         }
     };
     static_assert(specific_compiletime_string::value()[0] == 'a', "");
// passes!
}

And you can get char sequence in following way:
https://github.com/panaseleus/ctte/blob/master/proof_of_concept/proof_of_concept.cpp#L82-L86

> Thus, while I assume that it is faster than what happens inside the
> MPLLIBS_STRING (haven't measured it), its use is more limited, too.

As I understand, complexity of MPLLIBS_STRING comes from fact that it
can be passed immediately as template argument.

-- 
Evgeny Panasyuk

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk