diff --git a/include/bx/inline/typetraits.inl b/include/bx/inline/typetraits.inl index 64fad7c..8344f18 100644 --- a/include/bx/inline/typetraits.inl +++ b/include/bx/inline/typetraits.inl @@ -468,9 +468,9 @@ namespace bx template struct MakeSignedT { using Type = Ty; }; template using MakeSignedType = typename MakeSignedT::Type; - template struct MakeSignedT : AddConstType > {}; - template struct MakeSignedT : AddVolatileType> {}; - template struct MakeSignedT : AddCvType > {}; + template struct MakeSignedT : AddConstT > {}; + template struct MakeSignedT : AddVolatileT> {}; + template struct MakeSignedT : AddCvT > {}; template<> struct MakeSignedT< char > { using Type = signed char; }; template<> struct MakeSignedT< signed char > { using Type = signed char; }; @@ -485,18 +485,18 @@ namespace bx template<> struct MakeSignedT { using Type = signed long long; }; template - inline constexpr auto asSigned(Ty _t) + inline constexpr auto asSigned(Ty _value) { - return MakeSignedType(_t); + return MakeSignedType(_value); } //--- template struct MakeUnsignedT { using Type = Ty; }; template using MakeUnsignedType = typename MakeUnsignedT::Type; - template struct MakeUnsignedT : AddConstType > {}; - template struct MakeUnsignedT : AddVolatileType> {}; - template struct MakeUnsignedT : AddCvType > {}; + template struct MakeUnsignedT : AddConstT > {}; + template struct MakeUnsignedT : AddVolatileT> {}; + template struct MakeUnsignedT : AddCvT > {}; template<> struct MakeUnsignedT< char > { using Type = unsigned char; }; template<> struct MakeUnsignedT< signed char > { using Type = unsigned char; }; @@ -511,9 +511,9 @@ namespace bx template<> struct MakeUnsignedT { using Type = unsigned long long; }; template - inline constexpr auto asUnsigned(Ty _t) + inline constexpr auto asUnsigned(Ty _value) { - return MakeUnsignedType(_t); + return MakeUnsignedType(_value); } //--- diff --git a/include/bx/typetraits.h b/include/bx/typetraits.h index f0aab53..9460000 100644 --- a/include/bx/typetraits.h +++ b/include/bx/typetraits.h @@ -167,11 +167,11 @@ namespace bx /// Returns value of `_t` as signed type value. template - constexpr auto asSigned(Ty _t); + constexpr auto asSigned(Ty _value); /// Returns value of `_t` as unsigned type value. template - constexpr auto asUnsigned(Ty _t); + constexpr auto asUnsigned(Ty _value); /// Returns true if type `Ty` is integer type, otherwise returns false. template diff --git a/tests/typetraits_test.cpp b/tests/typetraits_test.cpp index c826129..01b4c0b 100644 --- a/tests/typetraits_test.cpp +++ b/tests/typetraits_test.cpp @@ -227,6 +227,20 @@ TEST_CASE("type-traits isTriviallyDestructible", "") STATIC_REQUIRE(!bx::isTriviallyDestructible() ); } +TEST_CASE("type-traits isConst", "") +{ + STATIC_REQUIRE(!bx::isConst() ); + STATIC_REQUIRE( bx::isConst() ); + STATIC_REQUIRE( bx::isConst>() ); +} + +TEST_CASE("type-traits isVolatile", "") +{ + STATIC_REQUIRE(!bx::isVolatile() ); + STATIC_REQUIRE( bx::isVolatile() ); + STATIC_REQUIRE( bx::isVolatile>() ); +} + TEST_CASE("type-traits isSigned", "") { STATIC_REQUIRE(!bx::isSigned() ); @@ -333,17 +347,14 @@ TEST_CASE("type-traits MakeSignedT", "") STATIC_REQUIRE(bx::isSigned::Type >() ); STATIC_REQUIRE(bx::isSigned::Type >() ); - enum struct E : unsigned short {}; - using char_type = std::make_signed_t; - using int_type = std::make_signed_t; - using long_type = std::make_signed_t; - using enum_type = std::make_signed_t; + using charType = bx::MakeSignedType; + using intType = bx::MakeSignedType; + using longType = bx::MakeSignedType; STATIC_REQUIRE(true - && bx::isSame() - && bx::isSame() - && bx::isSame() - && bx::isSame() + && bx::isSame() + && bx::isSame() + && bx::isSame() ); } @@ -377,14 +388,14 @@ TEST_CASE("type-traits MakeUnsignedT", "") STATIC_REQUIRE(bx::isUnsigned::Type >() ); STATIC_REQUIRE(bx::isUnsigned::Type >() ); - using uchar_type = std::make_unsigned_t; - using uint_type = std::make_unsigned_t; - using ulong_type = std::make_unsigned_t; + using ucharType = bx::MakeUnsignedType; + using uintType = bx::MakeUnsignedType; + using ulongType = bx::MakeUnsignedType; STATIC_REQUIRE(true - && bx::isSame() - && bx::isSame() - && bx::isSame() + && bx::isSame() + && bx::isSame() + && bx::isSame() ); }