且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在c ++ 11中定义否定的UDL(不允许使用?)?

更新时间:2023-11-29 19:25:22

整数文字必须接受为 unsigned long long code>。负号不是文字的一部分,而是在返回值之后应用。

Integer literals need to be accepted as unsigned long long. The negative sign is not part of the literal, it is applied after the fact, to the returned value.

constexpr int64_t operator "" _jpy(unsigned long long l)
{
  return static_cast<int64_t>(l);
}