C++11 User-Defined-Literals – Predefined Literals by Standard

c++c++11user-defined-literals

My question sounds like a contradiction, but I don't know how else to refer to the new literal syntax other than user-defined-literal.

std::string operator "" s ( const char* str, size_t len )
{
   return std::string( str, len );
}

assert( "foo"s == "bar"s );

I remember hearing that user defined literals should start with an _ prefix. That would imply that the library defines some non-prefixed literals for us.

Does the standard provide some UDLs in the the standard library?
If yes, what are they?

Best Answer

The standard library actually defines no user defined literals. We would perhaps have expected complex numbers, but no.

On the other hand, there is also a proposal to remove them again

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3250.html

so we don't yet know what happens.

Related Question