Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User-defined literals without underscore

According to cppreference it is possible to define a literal using

CSomeClass operator ""s(const char* literal, size_t size);

Now after reading the paragraph I think it should be also possible to define

CSomeClass operator ""r(const char* literal, size_t size);

(note the r ud-suffix instead of s)

Overloading s just gives the clang warning

warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]

which I can't really understand as I'm compiling with -std=c++14. Overloading r gives

error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
warning: user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator [-Wuser-defined-literals]

which seems even less accountable to me.

Why does clang emit these warnings/errors and how can I make the r ud-suffix valid.

like image 520
Uroc327 Avatar asked Mar 12 '15 18:03

Uroc327


1 Answers

User-defined literals must begin with the underscore _: the suffixes that do not begin with the underscore are reserved for the literal operators provided by the standard library.

like image 144
orlp Avatar answered Oct 02 '22 21:10

orlp