Get the signed/unsigned variant of an integer template parameter without explicit traits

前端 未结 2 968
清歌不尽
清歌不尽 2021-02-07 03:05

I am looking to define a template class whose template parameter will always be an integer type. The class will contain two members, one of type T, and the other as

相关标签:
2条回答
  • 2021-02-07 03:35

    If you can't or don't want to depend on TR1/C++0x features, Boost.TypeTraits also offers you make_unsigned<> et al.

    0 讨论(0)
  • 2021-02-07 03:47

    The answer is in <type_traits>

    For determining the signed-ness of a type use std::is_signed and std::is_unsigned.

    For adding/removing signed-ness, there is std::make_signed and std::make_unsigned.

    0 讨论(0)
提交回复
热议问题