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>> writes:

> [...]
> As it turns out, there has been such a proposal, N3599:
> later referenced by two competing proposals for compile-time string
> literals, N4121 and N4236:
> 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.


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