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
Post a Comment