clang 3.1(trunk) にユーザ定義リテラルが実装された
ねんがんの ゆーざていぎりてらるを てにいれたぞ!
[ソース]
#include <iostream> unsigned long long int operator "" _twice(unsigned long long int n){ return n + n; } template<char... cs> std::size_t operator "" _len(){ return sizeof...(cs); } std::string operator "" _reverse(char const* str, std::size_t size){ std::string result = str; return std::string(result.rbegin(), result.rend()); } int main(){ std::cout << 1234_twice << std::endl; std::cout << 3.14_len << std::endl; std::cout << "hello, world"_reverse << std::endl; return 0; }