我需要知道在指定noexcept说明符时是否定义了NDEBUG。我沿着这constexpr功能的思路思考:is_defined constexpr函数
constexpr inline bool is_defined() noexcept
{
return false;
}
constexpr inline bool is_defined(int) noexcept
{
return true;
}
然后使用它像:
void f() noexcept(is_defined(NDEBUG))
{
// blah, blah
}
是否标准库或已在各种语言的提供便利,这样我就不会重新发明轮子?
非常有趣的技巧。 – user1095108 2015-03-19 17:39:49