mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Fixed issue #285.
This commit is contained in:
@@ -144,37 +144,37 @@ namespace bx
|
||||
template<typename Ty>
|
||||
inline constexpr bool isEnum()
|
||||
{
|
||||
return __is_enum(Ty);
|
||||
return !!__is_enum(Ty);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
inline constexpr bool isUnion()
|
||||
{
|
||||
return __is_union(Ty);
|
||||
return !!__is_union(Ty);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
inline constexpr bool isAbstract()
|
||||
{
|
||||
return __is_abstract(Ty);
|
||||
return !!__is_abstract(Ty);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
inline constexpr bool isAggregate()
|
||||
{
|
||||
return __is_aggregate(Ty);
|
||||
return !!__is_aggregate(Ty);
|
||||
}
|
||||
|
||||
template<typename BaseT, typename DerivedT>
|
||||
inline constexpr bool isBaseOf()
|
||||
{
|
||||
return __is_base_of(BaseT, DerivedT);
|
||||
return !!__is_base_of(BaseT, DerivedT);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
inline constexpr bool isPolymorphic()
|
||||
{
|
||||
return __is_polymorphic(Ty);
|
||||
return !!__is_polymorphic(Ty);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
@@ -186,31 +186,31 @@ namespace bx
|
||||
template<typename Ty>
|
||||
inline constexpr bool isClass()
|
||||
{
|
||||
return __is_class(Ty);
|
||||
return !!__is_class(Ty);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
inline constexpr bool isFinal()
|
||||
{
|
||||
return __is_final(Ty);
|
||||
return !!__is_final(Ty);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
inline constexpr bool isEmpty()
|
||||
{
|
||||
return __is_empty(Ty);
|
||||
return !!__is_empty(Ty);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
inline constexpr bool isStandardLayout()
|
||||
{
|
||||
return __is_standard_layout(Ty);
|
||||
return !!__is_standard_layout(Ty);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
inline constexpr bool isTrivial()
|
||||
{
|
||||
return __is_trivial(Ty);
|
||||
return !!__is_trivial(Ty);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
@@ -224,7 +224,7 @@ namespace bx
|
||||
template<typename Ty, typename FromT>
|
||||
inline constexpr bool isAssignable()
|
||||
{
|
||||
return __is_assignable(Ty, FromT);
|
||||
return !!__is_assignable(Ty, FromT);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
@@ -248,7 +248,7 @@ namespace bx
|
||||
template<typename Ty, typename FromT>
|
||||
inline constexpr bool isTriviallyAssignable()
|
||||
{
|
||||
return __is_trivially_assignable(Ty, FromT);
|
||||
return !!__is_trivially_assignable(Ty, FromT);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
@@ -272,7 +272,7 @@ namespace bx
|
||||
template<typename Ty, typename... ArgsT>
|
||||
inline constexpr bool isConstructible()
|
||||
{
|
||||
return __is_constructible(Ty, ArgsT...);
|
||||
return !!__is_constructible(Ty, ArgsT...);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
@@ -290,7 +290,7 @@ namespace bx
|
||||
template<typename Ty, typename... ArgsT>
|
||||
inline constexpr bool isTriviallyConstructible()
|
||||
{
|
||||
return __is_trivially_constructible(Ty, ArgsT...);
|
||||
return !!__is_trivially_constructible(Ty, ArgsT...);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
@@ -308,16 +308,16 @@ namespace bx
|
||||
template<typename Ty>
|
||||
inline constexpr bool isTriviallyCopyable()
|
||||
{
|
||||
return __is_trivially_copyable(Ty);
|
||||
return !!__is_trivially_copyable(Ty);
|
||||
}
|
||||
|
||||
template<typename Ty>
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -655,3 +655,34 @@ TEST_CASE("type-traits isBaseOf", "")
|
||||
STATIC_REQUIRE(!bx::isBaseOf<TestClassDerivedB, TestClassDerivedX >() );
|
||||
STATIC_REQUIRE(!bx::isBaseOf<int32_t, int32_t >() );
|
||||
}
|
||||
|
||||
TEST_CASE("type-traits isAggregate", "")
|
||||
{
|
||||
STATIC_REQUIRE( bx::isAggregate<TestClass >() );
|
||||
STATIC_REQUIRE( bx::isAggregate<TestClassFinal >() );
|
||||
STATIC_REQUIRE(!bx::isAggregate<TestClassCtor >() );
|
||||
STATIC_REQUIRE( bx::isAggregate<TestClassMember >() );
|
||||
STATIC_REQUIRE(!bx::isAggregate<TestClassMemberPrivate >() );
|
||||
STATIC_REQUIRE( bx::isAggregate<TestClassStaticOnly >() );
|
||||
#if __cplusplus < BX_LANGUAGE_CPP20
|
||||
STATIC_REQUIRE( bx::isAggregate<TestClassDefaultCtor >() );
|
||||
#else
|
||||
STATIC_REQUIRE(!bx::isAggregate<TestClassDefaultCtor >() );
|
||||
#endif
|
||||
STATIC_REQUIRE( bx::isAggregate<TestClassDefaultDtor >() );
|
||||
STATIC_REQUIRE(!bx::isAggregate<TestClassVirtualDtor >() );
|
||||
STATIC_REQUIRE(!bx::isAggregate<TestClassAbstractBase >() );
|
||||
STATIC_REQUIRE(!bx::isAggregate<TestClassPolymorphic >() );
|
||||
#if __cplusplus < BX_LANGUAGE_CPP17
|
||||
STATIC_REQUIRE(!bx::isAggregate<TestClassDerivedA >() );
|
||||
STATIC_REQUIRE(!bx::isAggregate<TestClassDerivedB >() );
|
||||
#else
|
||||
STATIC_REQUIRE( bx::isAggregate<TestClassDerivedA >() );
|
||||
STATIC_REQUIRE( bx::isAggregate<TestClassDerivedB >() );
|
||||
#endif
|
||||
STATIC_REQUIRE(!bx::isAggregate<TestClassDerivedX >() );
|
||||
STATIC_REQUIRE( bx::isAggregate<TestUnion >() );
|
||||
STATIC_REQUIRE( bx::isAggregate<TestUnionEmpty >() );
|
||||
STATIC_REQUIRE( bx::isAggregate<TestUnion[] >() );
|
||||
STATIC_REQUIRE( bx::isAggregate<int32_t[] >() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user