Clang 3.1 claims to support user defined literals. I can define this:
int operator"" _tryit(long double n) { return int(n); }
but when I try to use it I get an error:
int m = 5_tryit;
Invalid suffix
'_tryit'
on integer constant
5
cannot be implicitly converted to a long double
in your case. You need to change it to 5.0
to make it a long double or explicitly invoke the function yourself for the implicit conversion to work:
int m = 5.0_tryit;
OR
int n = operator"" _tryit(5);
(tested both with clang version 3.1 (trunk) (llvm/trunk 155821)
)
This SO question has a good explanation of the rules.
(Also, as abarnert mentions, make sure you are passing the -std=c++11
flag to the compiler when compiling).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With