有没有办法在 C++03 编译器中获得 std::underlying_type 的等价物?
我知道 boost::type_traits 中有一些支持,但那里没有功能齐全的转换器。
最佳答案
this怎么样?解决方案?
template< class TpEnum >
struct UnderlyingType
{
typedef typename conditional<
TpEnum( -1 ) < TpEnum( 0 ),
typename make_signed< TpEnum >::type,
typename make_unsigned< TpEnum >::type
>::type type;
};
您可以找到它的构建 block (在 boost::type_traits 中有条件、make_signed、make_unsigned)
关于c++ - C++03 中 C++ 枚举的底层类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26148192/