meta: integral constant wrappers for intx_t and uintx_t added and fixed the type promotion on bit operations

This commit is contained in:
Christos Houtouridis
2019-01-29 15:57:26 +02:00
parent 734136a606
commit 903e4641f4
3 changed files with 56 additions and 13 deletions
+22 -1
View File
@@ -49,7 +49,7 @@ namespace meta {
//! integral_constant
//! An Integral Constant is a holder class for a compile-time value of an integral type.
//! Every Integral Constant is also a nullary Metafunction, returning itself.
//! Every Integral Constant is also a null-ary Metafunction, returning itself.
//! An integral constant object is implicitly convertible to the corresponding
//! run-time value of the wrapped integral type
//! @{
@@ -85,6 +85,27 @@ namespace meta {
using true_ = bool_<true>; //!< The type used as a compile-time boolean with true value.
using false_ = bool_<false>; //!< The type used as a compile-time boolean with false value.
//! int8_ type: integral constant wrapper for \c int8_t
template<int8_t _v>
using int8_ = integral_c<int8_t, _v>;
//! uint8_ type: integral constant wrapper for \c uint8_t
template<uint8_t _v>
using uint8_ = integral_c<uint8_t, _v>;
//! int16_ type: integral constant wrapper for \c int16_t
template<int16_t _v>
using int16_ = integral_c<int16_t, _v>;
//! uint16_ type: integral constant wrapper for \c uint16_t
template<uint16_t _v>
using uint16_ = integral_c<uint16_t, _v>;
//! int32_ type: integral constant wrapper for \c int32_t
template<int32_t _v>
using int32_ = integral_c<int32_t, _v>;
//! uint32_ type: integral constant wrapper for \c uint32_t
template<uint32_t _v>
using uint32_ = integral_c<uint32_t, _v>;
//! char_ type: integral constant wrapper for \c char
template<char _v>
using char_ = integral_c<char, _v>;
+3 -3
View File
@@ -108,7 +108,7 @@ namespace meta {
//! @{
//! \return bitwise not (~) operation of its argument.
template <typename _T> using bitnot_ = integral_c<decltype(~_T()), ~_T()>;
template <typename _T> using bitnot_ = integral_c<typename _T::value_type, (typename _T::value_type)(~_T())>;
//! \return bitwise and (&) operation of its arguments
template <typename _Tp1, typename _Tp2>
using bitand_ = integral_c<decltype(_Tp1() & _Tp2()), _Tp1() & _Tp2()>;
@@ -121,10 +121,10 @@ namespace meta {
using bitxor_ = integral_c<decltype(_Tp1() ^ _Tp2()), _Tp1() ^ _Tp2()>;
//! \return the result of bitwise shift left (<<) operation on _Tp.
template <typename _Tp, typename shift>
using shift_left = integral_c<decltype(_Tp() << shift()), (_Tp() << shift())>;
using shift_left = integral_c<typename _Tp::value_type, (typename _Tp::value_type)(_Tp() << shift())>;
//! \return the result of bitwise shift right (>>) operation on _Tp.
template <typename _Tp, typename shift>
using shift_right = integral_c<decltype(_Tp() >> shift()), (_Tp() >> shift())>;
using shift_right = integral_c<typename _Tp::value_type, (typename _Tp::value_type)(_Tp() >> shift())>;
//! @}
}}
//!@}