From 20a6d458984dd277f564827b8caaf6e96b4c72a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 27 Sep 2022 20:10:14 -0700 Subject: [PATCH] Fixed issue #285. --- include/bx/inline/typetraits.inl | 36 ++++++++++++++++---------------- include/bx/platform.h | 14 ++++++++++--- tests/typetraits_test.cpp | 31 +++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 21 deletions(-) diff --git a/include/bx/inline/typetraits.inl b/include/bx/inline/typetraits.inl index b623796..3af6a05 100644 --- a/include/bx/inline/typetraits.inl +++ b/include/bx/inline/typetraits.inl @@ -144,37 +144,37 @@ namespace bx template inline constexpr bool isEnum() { - return __is_enum(Ty); + return !!__is_enum(Ty); } template inline constexpr bool isUnion() { - return __is_union(Ty); + return !!__is_union(Ty); } template inline constexpr bool isAbstract() { - return __is_abstract(Ty); + return !!__is_abstract(Ty); } template inline constexpr bool isAggregate() { - return __is_aggregate(Ty); + return !!__is_aggregate(Ty); } template inline constexpr bool isBaseOf() { - return __is_base_of(BaseT, DerivedT); + return !!__is_base_of(BaseT, DerivedT); } template inline constexpr bool isPolymorphic() { - return __is_polymorphic(Ty); + return !!__is_polymorphic(Ty); } template @@ -186,31 +186,31 @@ namespace bx template inline constexpr bool isClass() { - return __is_class(Ty); + return !!__is_class(Ty); } template inline constexpr bool isFinal() { - return __is_final(Ty); + return !!__is_final(Ty); } template inline constexpr bool isEmpty() { - return __is_empty(Ty); + return !!__is_empty(Ty); } template inline constexpr bool isStandardLayout() { - return __is_standard_layout(Ty); + return !!__is_standard_layout(Ty); } template inline constexpr bool isTrivial() { - return __is_trivial(Ty); + return !!__is_trivial(Ty); } template @@ -224,7 +224,7 @@ namespace bx template inline constexpr bool isAssignable() { - return __is_assignable(Ty, FromT); + return !!__is_assignable(Ty, FromT); } template @@ -248,7 +248,7 @@ namespace bx template inline constexpr bool isTriviallyAssignable() { - return __is_trivially_assignable(Ty, FromT); + return !!__is_trivially_assignable(Ty, FromT); } template @@ -272,7 +272,7 @@ namespace bx template inline constexpr bool isConstructible() { - return __is_constructible(Ty, ArgsT...); + return !!__is_constructible(Ty, ArgsT...); } template @@ -290,7 +290,7 @@ namespace bx template inline constexpr bool isTriviallyConstructible() { - return __is_trivially_constructible(Ty, ArgsT...); + return !!__is_trivially_constructible(Ty, ArgsT...); } template @@ -308,16 +308,16 @@ namespace bx template inline constexpr bool isTriviallyCopyable() { - return __is_trivially_copyable(Ty); + return !!__is_trivially_copyable(Ty); } template inline constexpr bool isTriviallyDestructible() { #if BX_COMPILER_GCC - return __has_trivial_destructor(Ty); + return !!__has_trivial_destructor(Ty); #else - return __is_trivially_destructible(Ty); + return !!__is_trivially_destructible(Ty); #endif // BX_COMPILER_GCC } diff --git a/include/bx/platform.h b/include/bx/platform.h index d2519ec..f14f9b6 100644 --- a/include/bx/platform.h +++ b/include/bx/platform.h @@ -41,6 +41,12 @@ # define BX_CRT_NONE 0 #endif // BX_CRT_NONE +// Language standard version +#define BX_LANGUAGE_CPP14 201402L +#define BX_LANGUAGE_CPP17 201703L +#define BX_LANGUAGE_CPP20 202002L +#define BX_LANGUAGE_CPP23 202207L + // Platform #define BX_PLATFORM_ANDROID 0 #define BX_PLATFORM_BSD 0 @@ -439,12 +445,14 @@ #endif // BX_ARCH_ #if defined(__cplusplus) -# if __cplusplus < 201402L +# if __cplusplus < BX_LANGUAGE_CPP14 # error "C++14 standard support is required to build." -# elif __cplusplus < 201703L +# elif __cplusplus < BX_LANGUAGE_CPP17 # define BX_CPP_NAME "C++14" -# elif __cplusplus < 201704L +# elif __cplusplus < BX_LANGUAGE_CPP20 # define BX_CPP_NAME "C++17" +# elif __cplusplus < BX_LANGUAGE_CPP23 +# define BX_CPP_NAME "C++20" # else // See: https://gist.github.com/bkaradzic/2e39896bc7d8c34e042b#orthodox-c # define BX_CPP_NAME "C++WayTooModern" diff --git a/tests/typetraits_test.cpp b/tests/typetraits_test.cpp index d4bc0e8..aef3e08 100644 --- a/tests/typetraits_test.cpp +++ b/tests/typetraits_test.cpp @@ -655,3 +655,34 @@ TEST_CASE("type-traits isBaseOf", "") STATIC_REQUIRE(!bx::isBaseOf() ); STATIC_REQUIRE(!bx::isBaseOf() ); } + +TEST_CASE("type-traits isAggregate", "") +{ + STATIC_REQUIRE( bx::isAggregate() ); + STATIC_REQUIRE( bx::isAggregate() ); + STATIC_REQUIRE(!bx::isAggregate() ); + STATIC_REQUIRE( bx::isAggregate() ); + STATIC_REQUIRE(!bx::isAggregate() ); + STATIC_REQUIRE( bx::isAggregate() ); +#if __cplusplus < BX_LANGUAGE_CPP20 + STATIC_REQUIRE( bx::isAggregate() ); +#else + STATIC_REQUIRE(!bx::isAggregate() ); +#endif + STATIC_REQUIRE( bx::isAggregate() ); + STATIC_REQUIRE(!bx::isAggregate() ); + STATIC_REQUIRE(!bx::isAggregate() ); + STATIC_REQUIRE(!bx::isAggregate() ); +#if __cplusplus < BX_LANGUAGE_CPP17 + STATIC_REQUIRE(!bx::isAggregate() ); + STATIC_REQUIRE(!bx::isAggregate() ); +#else + STATIC_REQUIRE( bx::isAggregate() ); + STATIC_REQUIRE( bx::isAggregate() ); +#endif + STATIC_REQUIRE(!bx::isAggregate() ); + STATIC_REQUIRE( bx::isAggregate() ); + STATIC_REQUIRE( bx::isAggregate() ); + STATIC_REQUIRE( bx::isAggregate() ); + STATIC_REQUIRE( bx::isAggregate() ); +}