Boost logo

Boost :

Subject: Re: [boost] [Boost-interest] C++ library for runtime-concepts (type-erasure)
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2011-02-14 18:17:13


On 14/02/11 18:36, Germán Diago wrote:
> With constexpr + user-defined literals, I think this can be done:
>
> template <char...C>
> struct Var_Name {
> //expand here C...
> };
>
> And with user-defined literals:
>
> constexpr template <char... C> Var_Name<C...> operator _var();
>
> now:
>
> //We didn't loose the name!!!! Good c++0x...
> typedef tuple<Var_Name<"name"_var>...
>
> This should be valid c++0x.

Alas, I think not. In my reading of the standard (N3092, [lex.ext]),
only integer literals and floating point literals support the literal
operator template form (which is what you're trying to use here); for
string literals you only get the form

operator "" X(char*, size_t);

which is no good for compile-time lookup because it doesn't give
compile-time access to the chars.

Hoping I'm wrong,

John Bytheway


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