1)在运行时这些中的任何一个都比另一个更快吗?哪个,为什么?
2)这发生在编译时还是运行时?
unsigned short operator"" _ushort( unsigned long long arg ){ return arg; }
unsigned short my_var = 0x1234; // using type and literal
auto my_var = unsigned short(0x1234); // using auto and casting literal to type
auto my_var = 0x1234_ushort; // using auto and user defined literal to cast
编辑:使用constexpr有帮助吗?
constexpr unsigned short operator"" _ushort( unsigned long long arg ){ return arg; }