【发布时间】:2020-11-09 11:01:19
【问题描述】:
假设我想定义一个整数文字,它也允许负值,例如-12_km.
也就是说,我想做
using coord_t = long long;
coord_t operator "" _km(long long int);
但是,我的编译器 (gcc) 不接受这个。
The standard 提到了此类文字运算符的参数列表的允许类型列表,但其中没有带符号的整数类型。
为什么会有这样的标准?为什么它不允许用户定义的有符号整数文字?
【问题讨论】:
标签: c++ unsigned-integer user-defined-literals signed-integer negative-integer