c++ - Clang 3.1 and user defined literals -


clang 3.1 claims support user defined literals. can define this:

int operator"" _tryit(long double n) { return int(n); } 

but when try use error:

int m = 5_tryit; 

invalid suffix '_tryit' on integer constant

5 cannot implicitly converted long double in case. need change 5.0 make long double or explicitly invoke function implicit conversion work:

int m = 5.0_tryit; 

or

int n = operator"" _tryit(5); 

(tested both clang version 3.1 (trunk) (llvm/trunk 155821))

this question has explanation of rules.

(also, abarnert mentions, make sure passing -std=c++11 flag compiler when compiling).


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -