Boost logo

Boost :

Subject: Re: [boost] [metaparse] performance comparisons?
From: Louis Dionne (ldionne.2_at_[hidden])
Date: 2015-06-01 17:10:57


Peter Dimov <lists <at> pdimov.com> writes:

>
> [...]
>
> As it turns out, there has been such a proposal, N3599:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3599.html
>
> later referenced by two competing proposals for compile-time string
> literals, N4121 and N4236:
>
> https://isocpp.org/files/papers/n4121.pdf
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4236.html
>
> N3599 has been however rejected, as the committee apparently feels that
> representing compile-time strings as char packs is inefficient and
> impractical, and prefers constexpr char arrays.

`constexpr` char arrays and character packs are not equivalent. The problem
is that constexpr-ness is stripped away by argument passing. For illustration,
consider the following example:

    template <typename CompileTimeString>
    void f(CompileTimeString s) {
        static_assert(s == "abc", "");
    }

    constexpr std::string_literal<n> n4121 = "abc";
    constexpr auto n4236 = "abc"_s;

    f(n4121); // error: s is not constexpr within the body of f
    f(n4236); // ok: the value of s is contained in its type

The only way to achieve this with N4121 is to unpack the `std::string_literal`
into a template holding a character pack, passing this to `f` and then doing
the comparison with a character pack. But then this is equivalent to N4236.

Regards,
Louis


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