///////////////////////////////////////////////////////////////////////////// // Copyright (c) Electronic Arts Inc. All rights reserved. ///////////////////////////////////////////////////////////////////////////// #include "EASTLTest.h" #include #include #include #include "ConceptImpls.h" using namespace eastl; bool GetType(const true_type&) { return true; } bool GetType(const false_type&) { return false; } int GetType(const integral_constant&) { return 4; } int GetType(const integral_constant&) { return 8; } int GetType(const integral_constant&) { return 16; } int GetType(const integral_constant&) { return 32; } #ifdef _MSC_VER __declspec(align(32)) class ClassAlign32{ }; #else class ClassAlign32{ } __attribute__((aligned(32))); #endif struct Struct { // Empty }; class Class { // Empty }; class Subclass : public Class { // Empty }; class ClassEmpty { // Empty }; class ClassNonEmpty { public: int x; }; enum Enum { kValue1 }; union Union { int x; short y; }; struct FinalStruct final { }; class FinalClass final { }; #if !EASTL_TYPE_TRAIT_is_union_CONFORMANCE EASTL_DECLARE_UNION(Union) // We have to do this because is_union simply cannot work without user help. #endif // Used for union_cast tests below. // C++11 allows for PodA/PodB to have a trivial default (i.e. compiler-generated) constructor, // but as of this writing (3/2012) most C++ compilers don't have support for this yet. struct PodA{ int mX; }; struct PodB{ int mX; }; bool operator ==(const PodA& a1, const PodA& a2) { return (a1.mX == a2.mX); } // std::tr1::is_volatile::value == true if and only if, for a given type T: // * std::tr1::is_scalar::value == true, or // * T is a class or struct that has no user-defined copy assignment operator or destructor, // and T has no non-static data members M for which is_pod::value == false, and no members of reference type, or // * T is the type of an array of objects E for which is_pod::value == true // is_pod may only be applied to complete types. struct Pod1 { // Empty }; #if !EASTL_TYPE_TRAIT_is_pod_CONFORMANCE EASTL_DECLARE_POD(Pod1) // We have to do this because is_pod simply cannot work without user help. #endif #if !EASTL_TYPE_TRAIT_is_standard_layout_CONFORMANCE EASTL_DECLARE_STANDARD_LAYOUT(Pod1) // We have to do this because is_standard_layout simply cannot work without user help. #endif struct Pod2 { int mX; Pod1 mPod1; }; #if !EASTL_TYPE_TRAIT_is_pod_CONFORMANCE EASTL_DECLARE_POD(Pod2) #endif #if !EASTL_TYPE_TRAIT_is_standard_layout_CONFORMANCE EASTL_DECLARE_STANDARD_LAYOUT(Pod2) #endif struct Pod3 { Pod2 mPod2; int mX; Pod1 mPod1; }; #if !EASTL_TYPE_TRAIT_is_pod_CONFORMANCE EASTL_DECLARE_POD(Pod3) #endif #if !EASTL_TYPE_TRAIT_is_standard_layout_CONFORMANCE EASTL_DECLARE_STANDARD_LAYOUT(Pod3) #endif struct NonPod1 { NonPod1(){} virtual ~NonPod1(){} }; struct NonPod2 { virtual ~NonPod2(){} virtual void Function(){} }; #if EASTL_VARIABLE_TEMPLATES_ENABLED struct HasIncrementOperator { HasIncrementOperator& operator++() { return *this; } }; template> struct has_increment_operator : eastl::false_type {}; template struct has_increment_operator())>> : eastl::true_type {}; #endif // We use this for the is_copy_constructible test in order to verify that // is_copy_constructible in fact returns false for this type and not true. // std::is_copy_constructible specification: std::is_constructible::value is true. // Note that the specification refers to const T& and not T&. So we rig our class to // accept T& and not const T&. This situation is significant because as of this // writing the clang implementation appears to be broken and mis-implements // the is_copy_constructible type trait to return true for ConstructibleOnlyWithNonConstReference // when in fact it should return false. EA_DISABLE_VC_WARNING(4521) // disable warning : "multiple copy constructors specified" struct ConstructibleOnlyWithNonConstReference { ConstructibleOnlyWithNonConstReference(ConstructibleOnlyWithNonConstReference&) {} #if defined(EA_COMPILER_NO_DELETED_FUNCTIONS) private: ConstructibleOnlyWithNonConstReference() {} private: ConstructibleOnlyWithNonConstReference(const ConstructibleOnlyWithNonConstReference&) {} #else ConstructibleOnlyWithNonConstReference() = delete; ConstructibleOnlyWithNonConstReference(const ConstructibleOnlyWithNonConstReference&) = delete; #endif }; EA_RESTORE_VC_WARNING() #if defined(EA_COMPILER_NO_NOEXCEPT) //This is needed because VS2013 supports is_nothrow__xxx type traits but doesn't support C++11 noexcept. //So we use throw() to allow the is_nothrow_xxxx and similiar tests to work in VS2013 #define EASTL_TEST_NOEXCEPT throw() #else #define EASTL_TEST_NOEXCEPT EA_NOEXCEPT #endif struct ThrowConstructibleTest { ThrowConstructibleTest(const int = 0) EASTL_TEST_NOEXCEPT { } ThrowConstructibleTest(const float) EA_NOEXCEPT_IF(false) { } }; struct NoThrowAssignable { }; struct ThrowAssignableTest { void operator=(const NoThrowAssignable&) EASTL_TEST_NOEXCEPT { } void operator=(const ThrowAssignableTest&) { } }; struct NoThrowDestructible { ~NoThrowDestructible() EASTL_TEST_NOEXCEPT {} }; #if !defined(EA_COMPILER_NO_EXCEPTIONS) struct ThrowDestructible { ~ThrowDestructible() noexcept(false) { throw(int()); } }; struct ThrowDestructibleNoexceptFalse { virtual ~ThrowDestructibleNoexceptFalse() EA_NOEXCEPT_IF(false) { } }; #endif struct HasTrivialConstructor { int x; }; #if !EASTL_TYPE_TRAIT_has_trivial_constructor_CONFORMANCE EASTL_DECLARE_TRIVIAL_CONSTRUCTOR(HasTrivialConstructor) // We have to do this because has_trivial_constructor simply cannot work without user help. #endif #if !EASTL_TYPE_TRAIT_is_standard_layout_CONFORMANCE EASTL_DECLARE_STANDARD_LAYOUT(HasTrivialConstructor) #endif struct NoTrivialConstructor { NoTrivialConstructor() { px = &x; } int x; int* px; }; #if !EASTL_TYPE_TRAIT_is_standard_layout_CONFORMANCE EASTL_DECLARE_STANDARD_LAYOUT(NoTrivialConstructor) #endif struct HasTrivialCopy { void Function(){} int x; }; #if !EASTL_TYPE_TRAIT_has_trivial_constructor_CONFORMANCE EASTL_DECLARE_TRIVIAL_COPY(HasTrivialCopy) // We have to do this because has_trivial_copy simply cannot work without user help. #endif #if defined(EA_COMPILER_MSVC) && (_MSC_VER == 1900) // http://blogs.msdn.com/b/vcblog/archive/2014/06/06/c-14-stl-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1.aspx // VS2015-preview has a bug regarding C++14 implicit noexcept rules for destructors. We explicitly define noexcept below for VS2015-preview only. // // Re-evaluate when VS2015 RTM has been released. // struct NoTrivialCopy1 { virtual ~NoTrivialCopy1() EASTL_TEST_NOEXCEPT {} virtual void Function(){} }; #else struct NoTrivialCopy1 { virtual ~NoTrivialCopy1() {} virtual void Function(){} }; #endif struct NoTrivialCopy2 { NoTrivialCopy1 ntv; }; struct NonCopyable { NonCopyable() : mX(0) {} NonCopyable(int x) : mX(x) {} int mX; EA_NON_COPYABLE(NonCopyable) }; struct HasTrivialAssign { void Function(){} int x; }; #if !EASTL_TYPE_TRAIT_has_trivial_assign_CONFORMANCE EASTL_DECLARE_TRIVIAL_ASSIGN(HasTrivialAssign) // We have to do this because has_trivial_assign simply cannot work without user help. #endif struct NoTrivialAssign1 { virtual ~NoTrivialAssign1(){} virtual void Function(){} }; struct NoTrivialAssign2 { NoTrivialAssign1 nta; }; struct Polymorphic1 { virtual ~Polymorphic1(){} virtual void Function(){} }; struct Polymorphic2 : public Polymorphic1 { // Empty }; struct Polymorphic3 { virtual ~Polymorphic3(){} virtual void Function() = 0; }; struct NonPolymorphic1 { void Function(){} }; struct Abstract { #if defined(EA_COMPILER_GNUC) // GCC warns about this, so we include it for this class, even though for this compiler it partly defeats the purpose of its usage. virtual ~Abstract(){} #endif virtual void Function() = 0; }; struct AbstractWithDtor { virtual ~AbstractWithDtor(){} virtual void Function() = 0; }; struct DeletedDtor { #if !defined(EA_COMPILER_NO_DELETED_FUNCTIONS) ~DeletedDtor() = delete; #endif }; #if (EASTL_TYPE_TRAIT_is_destructible_CONFORMANCE == 0) EASTL_DECLARE_IS_DESTRUCTIBLE(DeletedDtor, false) #endif struct Assignable { void operator=(const Assignable&){} void operator=(const Pod1&){} }; class HiddenAssign { public: HiddenAssign(); private: HiddenAssign(const HiddenAssign& x); HiddenAssign& operator=(const HiddenAssign& x); }; #if !EASTL_TYPE_TRAIT_has_trivial_assign_CONFORMANCE EASTL_DECLARE_TRIVIAL_ASSIGN(HiddenAssign) #endif // This class exercises is_convertible for the case that the class has an explicit copy constructor. struct IsConvertibleTest1 { IsConvertibleTest1() {} IsConvertibleTest1(int, int) {} explicit IsConvertibleTest1(const IsConvertibleTest1&) {} ~IsConvertibleTest1(){} }; // Helpers for enable_if tests template typename eastl::enable_if::value, T>::type EnableIfTestFunction(T) { return 999; } template typename eastl::enable_if::value, T>::type EnableIfTestFunction(T) { return 888; } template typename eastl::disable_if::value, T>::type EnableIfTestFunction(T) { return 777; } // Test that EASTL_DECLARE_TRIVIAL_ASSIGN can be used to get around case whereby // the copy constructor and operator= are private. Normally vector requires this. // ** This is disabled because it turns out that vector in fact requires the // constructor for some uses. But we have code below which tests just part of vector. // template class eastl::vector; typedef char Array[32]; typedef const char ArrayConst[32]; typedef Class& Reference; typedef const Class& ConstReference; typedef const int ConstInt; typedef int Int; typedef volatile int VolatileInt; typedef const volatile int ConstVolatileInt; typedef int& IntReference; typedef const int& ConstIntReference; // Note here that the int is const, not the reference to the int. typedef const volatile int& ConstVolatileIntReference; // Note here that the int is const, not the reference to the int. typedef void FunctionVoidVoid(); typedef int FunctionIntVoid(); typedef int FunctionIntFloat(float); typedef void (*FunctionVoidVoidPtr)(); namespace { const eastl::string gEmptyStringInstance(""); const eastl::integral_constant gIntNullptrConstant; static_assert(gIntNullptrConstant() == nullptr, ""); } int TestTypeTraits() { int nErrorCount = 0; // static_min / static_max #if EASTL_TYPE_TRAIT_static_min_CONFORMANCE static_assert((static_min<3, 7, 1, 5>::value == 1), "static_min failure"); static_assert((static_max<3, 7, 1, 5>::value == 7), "static_max failure"); #else static_assert((static_min<7, 1>::value == 1), "static_min failure"); static_assert((static_max<7, 1>::value == 7), "static_max failure"); #endif // enable_if, disable_if. EATEST_VERIFY((EnableIfTestFunction((double)1.1) == 999)); EATEST_VERIFY((EnableIfTestFunction((int)1) == 888)); EATEST_VERIFY((EnableIfTestFunction((int)-4) == 888)); // conditional static_assert(sizeof(conditional::type) == sizeof(int8_t), "conditional failure"); static_assert(sizeof(conditional::type) == sizeof(int16_t), "conditional failure"); // bool_constant static_assert(bool_constant::value>::value == true, "bool_constant failure"); static_assert(bool_constant::value>::value == false, "bool_constant failure"); static_assert(is_same::type, integral_constant::type>::value, "bool_constant failure"); // identity static_assert(sizeof(identity::type) == sizeof(int), "identity failure"); static_assert((is_same::type >::value == true), "identity failure"); // type_identity static_assert(sizeof(type_identity::type) == sizeof(int), "type_identity failure"); static_assert((is_same::type >::value == true), "type_identity failure"); static_assert(sizeof(type_identity_t) == sizeof(int), "type_identity failure"); static_assert((is_same_v> == true), "type_identity failure"); // is_void static_assert(is_void::value == true, "is_void failure"); static_assert(is_void::value == true, "is_void failure"); static_assert(is_void::value == false, "is_void failure"); // is_null_pointer #if defined(EA_COMPILER_CPP11_ENABLED) #if !defined(EA_COMPILER_NO_DECLTYPE) && !defined(_MSC_VER) // VS2012 is broken for just the case of decltype(nullptr). static_assert(is_null_pointer::value == true, "is_null_pointer failure"); static_assert(is_null_pointer::value == false, "is_null_pointer failure"); #endif #if defined(EA_HAVE_nullptr_t_IMPL) static_assert(is_null_pointer::value == true, "is_null_pointer failure"); // Can't enable this until we are using an updated that is savvy to C++11 clang (defines nullptr) being used with C++98 GNU libstdc++ (defines std::nullptr_t). #endif static_assert(is_null_pointer::value == false, "is_null_pointer failure"); static_assert(is_null_pointer::value == false, "is_null_pointer failure"); #endif // is_integral static_assert(is_integral::value == true, "is_integral failure"); EATEST_VERIFY(GetType(is_integral()) == true); static_assert(is_integral::value == true, "is_integral failure"); EATEST_VERIFY(GetType(is_integral()) == true); static_assert(is_integral::value == false, "is_integral failure"); EATEST_VERIFY(GetType(is_integral()) == false); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); static_assert(is_integral::value, "is_integral failure"); #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type which is already handled... static_assert(is_integral::value, "is_integral failure"); #endif // is_floating_point static_assert(is_floating_point::value == true, "is_floating_point failure"); EATEST_VERIFY(GetType(is_floating_point()) == true); static_assert(is_floating_point::value == true, "is_floating_point failure"); EATEST_VERIFY(GetType(is_floating_point()) == true); static_assert(is_floating_point::value == false, "is_floating_point failure"); EATEST_VERIFY(GetType(is_floating_point()) == false); // is_arithmetic static_assert(is_arithmetic::value == true, "is_arithmetic failure"); static_assert(is_arithmetic_v == true, "is_arithmetic failure"); EATEST_VERIFY(GetType(is_arithmetic()) == true); static_assert(is_arithmetic::value == false, "is_arithmetic failure"); static_assert(is_arithmetic_v == false, "is_arithmetic failure"); EATEST_VERIFY(GetType(is_arithmetic()) == false); // is_fundamental static_assert(is_fundamental::value == true, "is_fundamental failure"); static_assert(is_fundamental_v == true, "is_fundamental failure"); EATEST_VERIFY(GetType(is_fundamental()) == true); #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type which is already handled... static_assert(is_fundamental::value == true, "is_fundamental failure"); static_assert(is_fundamental_v == true, "is_fundamental failure"); EATEST_VERIFY(GetType(is_fundamental()) == true); #endif static_assert(is_fundamental::value == false, "is_fundamental failure"); static_assert(is_fundamental_v == false, "is_fundamental failure"); EATEST_VERIFY(GetType(is_fundamental()) == false); static_assert(is_fundamental::value == true, "is_fundamental failure"); static_assert(is_fundamental_v == true, "is_fundamental failure"); // is_array static_assert(is_array::value == true, "is_array failure"); EATEST_VERIFY(GetType(is_array()) == true); static_assert(is_array::value == true, "is_array failure"); EATEST_VERIFY(GetType(is_array()) == true); static_assert(is_array::value == true, "is_array failure"); static_assert(is_array::value == false, "is_array failure"); EATEST_VERIFY(GetType(is_array()) == false); static_assert(is_array::value == false, "is_array failure"); EATEST_VERIFY(GetType(is_array()) == false); // is_reference static_assert(is_reference::value == true, "is_reference failure"); EATEST_VERIFY(GetType(is_reference()) == true); static_assert(is_reference::value == true, "is_reference failure"); EATEST_VERIFY(GetType(is_reference()) == true); static_assert(is_reference::value == false, "is_reference failure"); EATEST_VERIFY(GetType(is_reference()) == false); static_assert(is_reference::value == false, "is_reference failure"); EATEST_VERIFY(GetType(is_reference()) == false); // is_member_function_pointer static_assert(is_member_function_pointer::value == false, "is_member_function_pointer failure"); static_assert(is_member_function_pointer::value == false, "is_member_function_pointer failure"); static_assert(is_member_function_pointer::value == true, "is_member_function_pointer failure"); // is_member_object_pointer static_assert(is_member_object_pointer::value == false, "is_member_object_pointer failure"); static_assert(is_member_object_pointer::value == true, "is_member_object_pointer failure"); static_assert(is_member_object_pointer::value == false, "is_member_object_pointer failure"); // is_member_pointer static_assert(is_member_pointer::value == false, "is_member_pointer failure"); static_assert(is_member_pointer::value == true, "is_member_pointer failure"); static_assert(is_member_pointer::value == true, "is_member_pointer failure"); // is_pointer static_assert(is_pointer::value == true, "is_pointer failure"); static_assert(is_pointer::value == true, "is_pointer failure"); static_assert(is_pointer::value == false, "is_pointer failure"); static_assert(is_pointer::value == false, "is_pointer failure"); #if defined(EA_HAVE_nullptr_t_IMPL) static_assert(is_pointer::value == false, "is_pointer failure"); #endif // is_enum static_assert(is_enum::value == true, "is_enum failure "); static_assert(is_enum_v == true, "is_enum failure "); EATEST_VERIFY(GetType(is_enum()) == true); static_assert(is_enum::value == true, "is_enum failure "); static_assert(is_enum_v == true, "is_enum failure "); EATEST_VERIFY(GetType(is_enum()) == true); static_assert(is_enum::value == false, "is_enum failure "); static_assert(is_enum_v == false, "is_enum failure "); EATEST_VERIFY(GetType(is_enum()) == false); static_assert(is_enum::value == false, "is_enum failure "); static_assert(is_enum_v == false, "is_enum failure "); EATEST_VERIFY(GetType(is_enum()) == false); // is_union static_assert(is_union::value == true, "is_union failure"); static_assert(is_union_v == true, "is_union failure"); EATEST_VERIFY(GetType(is_union()) == true); static_assert(is_union::value == false, "is_union failure"); static_assert(is_union_v == false, "is_union failure"); EATEST_VERIFY(GetType(is_union()) == false); // is_class static_assert(is_class::value == true, "is_class failure"); EATEST_VERIFY(GetType(is_class()) == true); static_assert(is_class::value == true, "is_class failure"); EATEST_VERIFY(GetType(is_class()) == true); static_assert(is_class::value == false, "is_class failure"); EATEST_VERIFY(GetType(is_class()) == false); static_assert(is_class::value == false, "is_class failure"); EATEST_VERIFY(GetType(is_class()) == false); static_assert(is_class::value == false, "is_class failure"); EATEST_VERIFY(GetType(is_class()) == false); // is_function static_assert(is_function::value == false, "is_function failure"); static_assert(is_function::value == true, "is_function failure"); static_assert(is_function::value == false, "is_function failure"); static_assert(is_function::value == true, "is_function failure"); static_assert(is_function::value == true, "is_function failure"); static_assert(is_function::value == false, "is_function failure"); static_assert(is_function::value == false, "is_function failure"); static_assert(is_function::value == false, "is_function failure"); static_assert(is_function::value == false, "is_function failure"); static_assert(is_function::value == false, "is_function failure"); #if EASTL_TYPE_TRAIT_is_function_CONFORMANCE // typedef int PrintfConst(const char*, ...) const; static_assert(is_function::value == true, "is_function failure"); // This is the signature of printf. #endif static_assert(is_function_v == false, "is_function failure"); static_assert(is_function_v == true, "is_function failure"); static_assert(is_function_v == false, "is_function failure"); static_assert(is_function_v == true, "is_function failure"); static_assert(is_function_v == true, "is_function failure"); static_assert(is_function_v == false, "is_function failure"); static_assert(is_function_v == false, "is_function failure"); static_assert(is_function_v == false, "is_function failure"); static_assert(is_function_v == false, "is_function failure"); static_assert(is_function_v == false, "is_function failure"); #if EASTL_TYPE_TRAIT_is_function_CONFORMANCE // typedef int PrintfConst(const char*, ...) const; static_assert(is_function_v == true, "is_function failure"); // This is the signature of printf. #endif // is_object static_assert(is_object::value == true, "is_object failure"); EATEST_VERIFY(GetType(is_object()) == true); static_assert(is_object::value == true, "is_object failure"); EATEST_VERIFY(GetType(is_object()) == true); static_assert(is_object::value == true, "is_object failure"); EATEST_VERIFY(GetType(is_object()) == true); static_assert(is_object::value == false, "is_object failure"); EATEST_VERIFY(GetType(is_object()) == false); // is_scalar static_assert(is_scalar::value == true, "is_scalar failure"); EATEST_VERIFY(GetType(is_scalar()) == true); static_assert(is_scalar::value == true, "is_scalar failure"); EATEST_VERIFY(GetType(is_scalar()) == true); static_assert(is_scalar::value == true, "is_scalar failure"); EATEST_VERIFY(GetType(is_scalar()) == true); static_assert(is_scalar::value == true, "is_scalar failure"); EATEST_VERIFY(GetType(is_scalar()) == true); static_assert(is_scalar::value == true, "is_scalar failure"); // is_compound static_assert(is_compound::value == true, "is_compound failure"); EATEST_VERIFY(GetType(is_compound()) == true); static_assert(is_compound::value == true, "is_compound failure"); EATEST_VERIFY(GetType(is_compound()) == true); static_assert(is_compound::value == true, "is_compound failure"); EATEST_VERIFY(GetType(is_compound()) == true); static_assert(is_compound::value == false, "is_compound failure"); EATEST_VERIFY(GetType(is_compound()) == false); static_assert(is_compound::value == false, "is_compound failure"); EATEST_VERIFY(GetType(is_compound()) == false); // is_const static_assert(is_const::value == false, "is_const failure"); EATEST_VERIFY(GetType(is_const()) == false); static_assert(is_const::value == true, "is_const failure"); EATEST_VERIFY(GetType(is_const()) == true); static_assert(is_const::value == false, "is_const failure"); EATEST_VERIFY(GetType(is_const()) == false); static_assert(is_const::value == true, "is_const failure"); EATEST_VERIFY(GetType(is_const()) == true); static_assert(is_const::value == false, "is_const failure"); EATEST_VERIFY(GetType(is_const()) == false); static_assert(is_const::value == false, "is_const failure"); // Note here that the int is const, not the reference to the int. EATEST_VERIFY(GetType(is_const()) == false); static_assert(is_const::value == false, "is_const failure"); // Note here that the int is const, not the reference to the int. EATEST_VERIFY(GetType(is_const()) == false); // is_volatile static_assert(is_volatile::value == false, "is_volatile failure"); EATEST_VERIFY(GetType(is_volatile()) == false); static_assert(is_volatile::value == false, "is_volatile failure"); EATEST_VERIFY(GetType(is_volatile()) == false); static_assert(is_volatile::value == true, "is_volatile failure"); EATEST_VERIFY(GetType(is_volatile()) == true); static_assert(is_volatile::value == true, "is_volatile failure"); EATEST_VERIFY(GetType(is_volatile()) == true); static_assert(is_volatile::value == false, "is_volatile failure"); EATEST_VERIFY(GetType(is_volatile()) == false); static_assert(is_volatile::value == false, "is_volatile failure"); EATEST_VERIFY(GetType(is_volatile()) == false); static_assert(is_volatile::value == false, "is_volatile failure"); // Note here that the int is volatile, not the reference to the int. EATEST_VERIFY(GetType(is_volatile()) == false); // underlying_type #if EASTL_TYPE_TRAIT_underlying_type_CONFORMANCE && !defined(EA_COMPILER_NO_STRONGLY_TYPED_ENUMS) // If we can execute this test... enum UnderlyingTypeTest : uint16_t { firstVal = 0, secondVal = 1 }; static_assert(sizeof(underlying_type::type) == sizeof(uint16_t), "underlying_type failure"); #endif // is_literal_type static_assert((is_literal_type::value == true), "is_literal_type failure"); static_assert((is_literal_type::value == true), "is_literal_type failure"); #if EASTL_TYPE_TRAIT_is_literal_type_CONFORMANCE static_assert((is_literal_type::value == true), "is_literal_type failure"); static_assert((is_literal_type::value == false), "is_literal_type failure"); #endif // is_trivial // is_trivially_copyable // is_trivially_default_constructible #if EASTL_TYPE_TRAIT_is_trivial_CONFORMANCE static_assert(is_trivial::value == true, "is_trivial failure"); static_assert(is_trivial::value == false, "is_trivial failure"); #endif // is_pod static_assert(is_pod::value == true, "is_pod failure"); EATEST_VERIFY(GetType(is_pod()) == true); static_assert(is_pod::value == true, "is_pod failure"); EATEST_VERIFY(GetType(is_pod()) == true); static_assert(is_pod::value == true, "is_pod failure"); EATEST_VERIFY(GetType(is_pod()) == true); static_assert(is_pod::value == true, "is_pod failure"); EATEST_VERIFY(GetType(is_pod()) == true); static_assert(is_pod::value == true, "is_pod failure"); EATEST_VERIFY(GetType(is_pod()) == true); static_assert(is_pod::value == false, "is_pod failure"); EATEST_VERIFY(GetType(is_pod()) == false); static_assert(is_pod::value == false, "is_pod failure"); EATEST_VERIFY(GetType(is_pod()) == false); // is_standard_layout static_assert(is_standard_layout::value == true, "is_standard_layout failure"); static_assert(is_standard_layout_v == true, "is_standard_layout failure"); EATEST_VERIFY(GetType(is_standard_layout()) == true); static_assert(is_standard_layout::value == true, "is_standard_layout failure"); static_assert(is_standard_layout_v == true, "is_standard_layout failure"); EATEST_VERIFY(GetType(is_standard_layout()) == true); static_assert(is_standard_layout::value == true, "is_standard_layout failure"); static_assert(is_standard_layout_v == true, "is_standard_layout failure"); EATEST_VERIFY(GetType(is_standard_layout()) == true); static_assert(is_standard_layout::value == true, "is_standard_layout failure"); static_assert(is_standard_layout_v == true, "is_standard_layout failure"); EATEST_VERIFY(GetType(is_standard_layout()) == true); static_assert(is_standard_layout::value == true, "is_standard_layout failure"); static_assert(is_standard_layout_v == true, "is_standard_layout failure"); EATEST_VERIFY(GetType(is_standard_layout()) == true); static_assert(is_standard_layout::value == false, "is_standard_layout failure"); static_assert(is_standard_layout_v == false, "is_standard_layout failure"); EATEST_VERIFY(GetType(is_standard_layout()) == false); static_assert(is_standard_layout::value == false, "is_standard_layout failure"); static_assert(is_standard_layout_v == false, "is_standard_layout failure"); EATEST_VERIFY(GetType(is_standard_layout()) == false); static_assert(is_standard_layout::value == true, "is_standard_layout failure"); static_assert(is_standard_layout_v == true, "is_standard_layout failure"); EATEST_VERIFY(GetType(is_standard_layout()) == true); static_assert(is_standard_layout::value == true, "is_standard_layout failure"); // A key difference between a POD and Standard Layout is that the latter is true if there is a constructor. static_assert(is_standard_layout_v == true, "is_standard_layout failure"); // A key difference between a POD and Standard Layout is that the latter is true if there is a constructor. EATEST_VERIFY(GetType(is_standard_layout()) == true); // is_empty static_assert(is_empty::value == true, "is_empty failure"); EATEST_VERIFY(GetType(is_empty()) == true); static_assert(is_empty::value == false, "is_empty failure"); EATEST_VERIFY(GetType(is_empty()) == false); static_assert(is_empty::value == false, "is_empty failure"); EATEST_VERIFY(GetType(is_empty()) == false); static_assert(is_empty::value == false, "is_empty failure"); EATEST_VERIFY(GetType(is_empty()) == false); // is_polymorphic static_assert(is_polymorphic::value == true, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(is_polymorphic()) == true); static_assert(is_polymorphic::value == true, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(is_polymorphic()) == true); static_assert(is_polymorphic::value == true, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(is_polymorphic()) == true); static_assert(is_polymorphic::value == false, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(is_polymorphic()) == false); static_assert(is_polymorphic::value == false, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(is_polymorphic()) == false); static_assert(is_polymorphic::value == false, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(is_polymorphic()) == false); // has_trivial_constructor static_assert(has_trivial_constructor::value == true, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(has_trivial_constructor()) == true); static_assert(has_trivial_constructor::value == true, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(has_trivial_constructor()) == true); static_assert(has_trivial_constructor::value == true, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(has_trivial_constructor()) == true); static_assert(has_trivial_constructor::value == false, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(has_trivial_constructor()) == false); static_assert(has_trivial_constructor::value == false, "has_trivial_constructor failure"); EATEST_VERIFY(GetType(has_trivial_constructor()) == false); // has_trivial_copy static_assert(has_trivial_copy::value == true, "has_trivial_copy failure"); EATEST_VERIFY(GetType(has_trivial_copy()) == true); static_assert(has_trivial_copy::value == true, "has_trivial_copy failure"); EATEST_VERIFY(GetType(has_trivial_copy()) == true); static_assert(has_trivial_copy::value == true, "has_trivial_copy failure"); EATEST_VERIFY(GetType(has_trivial_copy()) == true); static_assert(has_trivial_copy::value == false, "has_trivial_copy failure"); EATEST_VERIFY(GetType(has_trivial_copy()) == false); static_assert(has_trivial_copy::value == false, "has_trivial_copy failure"); EATEST_VERIFY(GetType(has_trivial_copy()) == false); // has_trivial_assign static_assert(has_trivial_assign::value == true, "has_trivial_assign failure"); EATEST_VERIFY(GetType(has_trivial_assign()) == true); static_assert(has_trivial_assign::value == true, "has_trivial_assign failure"); EATEST_VERIFY(GetType(has_trivial_assign()) == true); static_assert(has_trivial_assign::value == true, "has_trivial_assign failure"); EATEST_VERIFY(GetType(has_trivial_assign()) == true); static_assert(has_trivial_assign::value == false, "has_trivial_assign failure"); EATEST_VERIFY(GetType(has_trivial_assign()) == false); static_assert(has_trivial_assign::value == false, "has_trivial_assign failure"); EATEST_VERIFY(GetType(has_trivial_assign()) == false); // has_trivial_destructor static_assert(has_trivial_assign::value == true, "has_trivial_relocate failure"); EATEST_VERIFY(GetType(has_trivial_assign()) == true); static_assert(has_trivial_assign::value == true, "has_trivial_relocate failure"); EATEST_VERIFY(GetType(has_trivial_assign()) == true); // has_trivial_relocate static_assert(has_trivial_relocate::value == true, "has_trivial_relocate failure"); EATEST_VERIFY(GetType(has_trivial_relocate()) == true); static_assert(has_trivial_relocate::value == true, "has_trivial_relocate failure"); EATEST_VERIFY(GetType(has_trivial_relocate()) == true); // is_signed static_assert(is_signed::value == true, "is_signed failure "); static_assert(is_signed_v == true, "is_signed failure "); EATEST_VERIFY(GetType(is_signed()) == true); static_assert(is_signed::value == true, "is_signed failure "); static_assert(is_signed_v == true, "is_signed failure "); EATEST_VERIFY(GetType(is_signed()) == true); static_assert(is_signed::value == false, "is_signed failure "); static_assert(is_signed_v == false, "is_signed failure "); EATEST_VERIFY(GetType(is_signed()) == false); static_assert(is_signed::value == false, "is_signed failure "); static_assert(is_signed_v == false, "is_signed failure "); EATEST_VERIFY(GetType(is_signed()) == false); static_assert(is_signed::value == true, "is_signed failure "); static_assert(is_signed_v == true, "is_signed failure "); EATEST_VERIFY(GetType(is_signed()) == true); static_assert(is_signed::value == true, "is_signed failure "); static_assert(is_signed_v == true, "is_signed failure "); EATEST_VERIFY(GetType(is_signed()) == true); // is_unsigned static_assert(is_unsigned::value == true, "is_unsigned failure "); static_assert(is_unsigned_v == true, "is_unsigned failure "); EATEST_VERIFY(GetType(is_unsigned()) == true); static_assert(is_unsigned::value == true, "is_unsigned failure "); static_assert(is_unsigned_v == true, "is_unsigned failure "); EATEST_VERIFY(GetType(is_unsigned()) == true); static_assert(is_unsigned::value == false, "is_unsigned failure "); static_assert(is_unsigned_v == false, "is_unsigned failure "); EATEST_VERIFY(GetType(is_unsigned()) == false); static_assert(is_unsigned::value == false, "is_unsigned failure "); static_assert(is_unsigned_v == false, "is_unsigned failure "); EATEST_VERIFY(GetType(is_unsigned()) == false); static_assert(is_unsigned::value == false, "is_unsigned failure "); static_assert(is_unsigned_v == false, "is_unsigned failure "); EATEST_VERIFY(GetType(is_unsigned()) == false); static_assert(is_unsigned::value == false, "is_unsigned failure "); static_assert(is_unsigned_v == false, "is_unsigned failure "); EATEST_VERIFY(GetType(is_unsigned()) == false); // is_lvalue_reference static_assert((is_lvalue_reference::value == false), "is_lvalue_reference failure"); static_assert((is_lvalue_reference::value == true), "is_lvalue_reference failure"); static_assert((is_lvalue_reference::value == false), "is_lvalue_reference failure"); static_assert((is_lvalue_reference::value == false), "is_lvalue_reference failure"); static_assert((is_lvalue_reference::value == true), "is_lvalue_reference failure"); static_assert((is_lvalue_reference::value == false), "is_lvalue_reference failure"); static_assert((is_lvalue_reference_v == false), "is_lvalue_reference failure"); static_assert((is_lvalue_reference_v == true), "is_lvalue_reference failure"); static_assert((is_lvalue_reference_v == false), "is_lvalue_reference failure"); static_assert((is_lvalue_reference_v == false), "is_lvalue_reference failure"); static_assert((is_lvalue_reference_v == true), "is_lvalue_reference failure"); static_assert((is_lvalue_reference_v == false), "is_lvalue_reference failure"); // is_rvalue_reference static_assert((is_rvalue_reference::value == false), "is_rvalue_reference failure"); static_assert((is_rvalue_reference::value == false), "is_rvalue_reference failure"); static_assert((is_rvalue_reference::value == true), "is_rvalue_reference failure"); static_assert((is_rvalue_reference::value == false), "is_rvalue_reference failure"); static_assert((is_rvalue_reference::value == false), "is_rvalue_reference failure"); static_assert((is_rvalue_reference::value == true), "is_rvalue_reference failure"); static_assert((is_rvalue_reference_v == false), "is_rvalue_reference failure"); static_assert((is_rvalue_reference_v == false), "is_rvalue_reference failure"); static_assert((is_rvalue_reference_v == true), "is_rvalue_reference failure"); static_assert((is_rvalue_reference_v == false), "is_rvalue_reference failure"); static_assert((is_rvalue_reference_v == false), "is_rvalue_reference failure"); static_assert((is_rvalue_reference_v == true), "is_rvalue_reference failure"); // is_assignable // See the documentation for is_assignable to understand the results below are as they are. static_assert((eastl::is_assignable::value == true), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); #if EASTL_TYPE_TRAIT_is_assignable_CONFORMANCE // These might not succeed unless the implementation is conforming. static_assert((eastl::is_assignable::value == true), "is_assignable failure"); static_assert((eastl::is_assignable::value == true), "is_assignable failure"); static_assert((eastl::is_assignable::value == true), "is_assignable failure"); // These cannot succeed unless the implementation is conforming. static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); static_assert((eastl::is_assignable::value == false), "is_assignable failure"); #endif // is_lvalue_assignable static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == false), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == false), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == false), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == false), "is_lvalue_assignable failure"); #if EASTL_TYPE_TRAIT_is_lvalue_assignable_CONFORMANCE // These might not succeed unless the implementation is conforming. static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); // These cannot succeed unless the implementation is conforming. static_assert((eastl::is_lvalue_assignable::value == false), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == false), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == false), "is_lvalue_assignable failure"); static_assert((eastl::is_lvalue_assignable::value == false), "is_lvalue_assignable failure"); // Despite that you can memcpy these, C++ syntax doesn't all =-based assignment. #if !defined(EA_COMPILER_EDG) // EDG (and only EDG) is issuing int8_t->double conversion warnings from the decltype expression inside this trait. That's probably a compiler bug, though we need to verify. static_assert((eastl::is_lvalue_assignable::value == true), "is_lvalue_assignable failure"); // Sure this might generate a warning, but it's valid syntax. #endif #endif // is_copy_assignable static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); #if EASTL_TYPE_TRAIT_is_assignable_CONFORMANCE // These might not succeed unless the implementation is conforming. static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); // These cannot succeed unless the implementation is conforming. static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == false), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == false), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == true), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == false), "is_copy_assignable failure"); static_assert((eastl::is_copy_assignable::value == false), "is_copy_assignable failure"); #endif // is_trivially_assignable static_assert((eastl::is_trivially_assignable::value == true), "is_trivially_assignable failure"); static_assert((eastl::is_trivially_assignable::value == false), "is_trivially_assignable failure"); static_assert((eastl::is_trivially_assignable::value == false), "is_trivially_assignable failure"); static_assert((eastl::is_trivially_assignable::value == false), "is_trivially_assignable failure"); static_assert((eastl::is_trivially_assignable::value == false), "is_trivially_assignable failure"); // False because not trivial. static_assert((eastl::is_trivially_assignable::value == false), "is_trivially_assignable failure"); // False because not trivial. static_assert((eastl::is_trivially_assignable::value == false), "is_trivially_assignable failure"); // is_nothrow_assignable static_assert((is_nothrow_assignable::value == false), "is_nothrow_assignable failure"); static_assert((is_nothrow_assignable::value == false), "is_nothrow_assignable failure"); // See is_assignable for why this is so. static_assert((is_nothrow_assignable::value == true), "is_nothrow_assignable failure"); static_assert((is_nothrow_assignable::value == false), "is_nothrow_assignable failure"); #if EASTL_TYPE_TRAIT_is_nothrow_assignable_CONFORMANCE static_assert((is_nothrow_assignable::value == true), "is_nothrow_assignable failure"); static_assert((is_nothrow_assignable::value == true), "is_nothrow_assignable failure"); static_assert((is_nothrow_assignable::value == true), "is_nothrow_assignable failure"); static_assert((is_nothrow_assignable::value == false), "is_nothrow_assignable failure"); #endif // is_array_of_known_bounds // is_array_of_unknown_bounds static_assert(is_array_of_known_bounds::value == false, "is_array_of_known_bounds failure"); static_assert(is_array_of_known_bounds::value == false, "is_array_of_known_bounds failure"); static_assert(is_array_of_known_bounds::value == false, "is_array_of_known_bounds failure"); static_assert(is_array_of_known_bounds::value == true, "is_array_of_known_bounds failure"); static_assert(is_array_of_known_bounds::value == false, "is_array_of_known_bounds failure"); static_assert(is_array_of_unknown_bounds::value == false, "is_array_of_known_bounds failure"); static_assert(is_array_of_unknown_bounds::value == false, "is_array_of_known_bounds failure"); static_assert(is_array_of_unknown_bounds::value == false, "is_array_of_known_bounds failure"); static_assert(is_array_of_unknown_bounds::value == false, "is_array_of_known_bounds failure"); static_assert(is_array_of_unknown_bounds::value == true, "is_array_of_known_bounds failure"); // is_trivially_copyable static_assert(is_trivially_copyable::value == false, "is_trivially_copyable failure"); static_assert(is_trivially_copyable::value == true, "is_trivially_copyable failure"); static_assert(is_trivially_copyable::value == true, "is_trivially_copyable failure"); static_assert(is_trivially_copyable::value == true, "is_trivially_copyable failure"); static_assert(is_trivially_copyable::value == true, "is_trivially_copyable failure"); #if EASTL_TYPE_TRAIT_is_trivially_copyable_CONFORMANCE static_assert(is_trivially_copyable::value == false, "is_trivially_copyable failure"); static_assert(is_trivially_copyable::value == false, "is_trivially_copyable failure"); static_assert(is_trivially_copyable::value == true, "is_trivially_copyable failure"); #endif { // user reported regression struct Foo { int a; Foo(int i) : a(i) {} Foo(Foo&& other) : a(other.a) { other.a = 0; } Foo(const Foo&) = delete; Foo& operator=(const Foo&) = delete; }; static_assert(!eastl::is_trivially_copyable::value, "is_trivially_copyable failure"); } // is_trivially_copy_assignable { static_assert(is_trivially_copy_assignable::value == true, "is_trivially_copy_assignable failure"); static_assert(is_trivially_copy_assignable::value == true, "is_trivially_copy_assignable failure"); static_assert(is_trivially_copy_assignable::value == true, "is_trivially_copy_assignable failure"); static_assert(is_trivially_copy_assignable::value == false, "is_trivially_copy_assignable failure"); #ifdef INTENTIONALLY_DISABLED // These tests currently fail on clang, but they would pass using the std::is_trivially_copy_assignable trait. We should // determine if our implementation is correct, or if clang is actually incorrect. static_assert(is_trivially_copy_assignable::value == true, "is_trivially_copy_assignable failure"); static_assert(is_trivially_copy_assignable::value == true, "is_trivially_copy_assignable failure"); static_assert(is_trivially_copy_assignable::value == true, "is_trivially_copy_assignable failure"); #endif } // is_trivially_default_constructible // To do. // is_trivial // To do. // is_constructible static_assert(is_constructible::value == false, "is_constructible failure"); static_assert(is_constructible::value == false, "is_constructible failure"); static_assert(is_constructible::value == true, "is_constructible failure"); static_assert(is_constructible::value == false, "is_constructible failure"); static_assert(is_constructible::value == true, "is_constructible failure"); static_assert(is_constructible::value == false, "is_constructible failure"); static_assert(is_constructible::value == true, "is_constructible failure"); static_assert(is_constructible::value == true, " is_constructible failure"); static_assert(is_constructible::value == true, "is_constructible failure"); static_assert(is_constructible::value == true, "is_constructible failure"); static_assert(is_constructible::value == false, "is_constructible failure"); static_assert(is_constructible::value == true, "is_constructible failure"); #if EASTL_TYPE_TRAIT_is_trivially_constructible_CONFORMANCE static_assert((is_constructible::value == true), "is_constructible failure"); static_assert((is_constructible::value == false), "is_constructible failure"); static_assert((is_constructible::value == true), "is_constructible failure"); static_assert((is_constructible::value == true), "is_constructible failure"); static_assert((is_constructible::value == true), "is_constructible failure"); #endif // is_trivially_constructible // Need double parentheses because some older compilers need static_assert implemented as a macro. static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == true), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == true), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == true), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == true), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); #if EASTL_TYPE_TRAIT_is_trivially_constructible_CONFORMANCE static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == true), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == true), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); static_assert((is_trivially_constructible::value == false), "is_trivially_constructible failure"); #endif // is_nothrow_constructible static_assert((is_nothrow_constructible::value == false), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == true), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == true), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == true), "is_nothrow_constructible failure"); #if EASTL_TYPE_TRAIT_is_nothrow_constructible_CONFORMANCE static_assert((is_nothrow_constructible::value == false), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == false), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == true), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == false), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == true), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == false), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == true), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == true), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == false), "is_nothrow_constructible failure"); static_assert((is_nothrow_constructible::value == true), "is_nothrow_constructible failure"); //True because it's a compiler-generated constructor. #endif // is_nothrow_move_constructible #if !defined(EA_PLATFORM_MICROSOFT) static_assert((is_nothrow_move_constructible::value == false), "is_nothrow_move_constructible failure"); static_assert((is_nothrow_move_constructible::value == true), "is_nothrow_move_constructible failure"); static_assert((is_nothrow_move_constructible::value == true), "is_nothrow_move_constructible failure"); static_assert((is_nothrow_move_constructible::value == true), "is_nothrow_move_constructible failure"); static_assert((is_nothrow_move_constructible::value == true), "is_nothrow_move_constructible failure"); static_assert((is_nothrow_move_constructible::value == true), "is_nothrow_move_constructible failure"); static_assert((is_nothrow_move_constructible::value == true), "is_nothrow_move_constructible failure"); #endif // is_copy_constructible static_assert((is_copy_constructible::value == false), "is_copy_constructible failure"); #if EASTL_TYPE_TRAIT_is_copy_constructible_CONFORMANCE static_assert((is_copy_constructible::value == true), "is_copy_constructible failure"); static_assert((is_copy_constructible::value == true), "is_copy_constructible failure"); static_assert((is_copy_constructible::value == true), "is_copy_constructible failure"); // As of this writing, GCC's libstdc++ reports true for this. I'm trying to find what's correct. static_assert((is_copy_constructible::value == true), "is_copy_constructible failure"); static_assert((is_copy_constructible::value == true), "is_copy_constructible failure"); #if !defined(EA_COMPILER_EDG) && !defined(EA_COMPILER_MSVC) // EDG (and only EDG) is generating warnings about the decltype expression referencing a deleted constructor. This seems like a bug, though we need to verify. // EA_COMPILER_MSVC is disabled because VS2013 fails this test and it may be that EASTL_TYPE_TRAIT_is_copy_constructible_CONFORMANCE should really be 0 for VS2013. static_assert((is_copy_constructible::value == false), "is_copy_constructible failure"); #endif #endif // is_destructible static_assert(is_destructible::value == true, "is_destructible failure"); static_assert(is_destructible::value == true, "is_destructible failure"); static_assert(is_destructible::value == true, "is_destructible failure"); static_assert(is_destructible::value == true, "is_destructible failure"); static_assert(is_destructible::value == false, "is_destructible failure"); static_assert(is_destructible::value == true, "is_destructible failure"); static_assert(is_destructible::value == false, "is_destructible failure"); // You can't call operator delete on this class. static_assert(is_destructible::value == false, "is_destructible failure"); // You can't call operator delete on this class. static_assert(is_destructible::value == false, "is_destructible failure"); // You can't call operator delete on this class. #if !defined(EA_COMPILER_NO_DELETED_FUNCTIONS) static_assert(is_destructible::value == false, "is_destructible failure"); // You can't call operator delete on this class. #endif static_assert(is_destructible::value == true, "is_destructible failure"); // is_trivially_destructible static_assert(is_trivially_destructible::value == true, "is_trivially_destructible failure"); static_assert(is_trivially_destructible::value == true, "is_trivially_destructible failure"); static_assert(is_trivially_destructible::value == true, "is_trivially_destructible failure"); static_assert(is_trivially_destructible::value == false, "is_trivially_destructible failure"); #if EASTL_TYPE_TRAIT_is_trivially_destructible_CONFORMANCE static_assert(is_trivially_destructible::value == true, "is_trivially_destructible failure"); static_assert(is_trivially_destructible::value == true, "is_trivially_destructible failure"); static_assert(is_trivially_destructible::value == false, "is_trivially_destructible failure"); static_assert(is_trivially_destructible::value == false, "is_trivially_destructible failure"); static_assert(is_trivially_destructible::value == false, "is_trivially_destructible failure"); static_assert(is_trivially_destructible::value == false, "is_trivially_destructible failure"); static_assert(is_trivially_destructible::value == false, "is_trivially_destructible failure"); // This case differs from is_destructible, because we have a declared destructor. #endif // is_nothrow_destructible static_assert(is_nothrow_destructible::value == true, "is_nothrow_destructible failure"); static_assert(is_nothrow_destructible::value == false, "is_nothrow_destructible failure"); #if EASTL_TYPE_TRAIT_is_nothrow_destructible_CONFORMANCE static_assert(is_nothrow_destructible::value == true, "is_nothrow_destructible failure"); // NonPod2 is nothrow destructible because it has an empty destructor (makes no calls) which has no exception specification. Thus its exception specification defaults to noexcept(true) [C++11 Standard, 15.4 paragraph 14] static_assert(is_nothrow_destructible::value == true, "is_nothrow_destructible failure"); #endif #if EASTL_TYPE_TRAIT_is_nothrow_destructible_CONFORMANCE && !defined(EA_COMPILER_NO_EXCEPTIONS) static_assert(is_nothrow_destructible::value == false, "is_nothrow_destructible failure"); static_assert(is_nothrow_destructible::value == false, "is_nothrow_destructible failure"); #endif // alignment_of #if !defined(EA_ABI_ARM_APPLE) // Apple on ARM (i.e. iPhone/iPad) doesn't align 8 byte types on 8 byte boundaries, and the hardware allows it. static_assert(alignment_of::value == 8, "alignment_of failure"); EATEST_VERIFY(GetType(alignment_of()) == 8); #endif static_assert(alignment_of::value == 32, "alignment_of failure"); EATEST_VERIFY(GetType(alignment_of()) == 32); // common_type static_assert((is_same::type, NonPod2*>::value), "common_type failure"); static_assert((is_same::type, int>::value), "common_type failure"); static_assert((is_same::type, void>::value), "common_type failure"); static_assert((is_same::type, int>::value), "common_type failure"); // rank static_assert(rank::value == 6, "rank failure"); static_assert(rank::value == 3, "rank failure"); static_assert(rank::value == 0, "rank failure"); static_assert(rank::value == 0, "rank failure"); static_assert(rank_v == 6, "rank failure"); static_assert(rank_v == 3, "rank failure"); static_assert(rank_v == 0, "rank failure"); static_assert(rank_v == 0, "rank failure"); // extent static_assert((extent ::value == 0), "extent failure"); static_assert((extent ::value == 2), "extent failure"); static_assert((extent ::value == 2), "extent failure"); static_assert((extent ::value == 0), "extent failure"); static_assert((extent ::value == 0), "extent failure"); static_assert((extent ::value == 0), "extent failure"); static_assert((extent ::value == 0), "extent failure"); static_assert((extent::value == 4), "extent failure"); static_assert((extent ::value == 4), "extent failure"); static_assert((extent_v == 0), "extent failure"); static_assert((extent_v == 2), "extent failure"); static_assert((extent_v == 2), "extent failure"); static_assert((extent_v == 0), "extent failure"); static_assert((extent_v == 0), "extent failure"); static_assert((extent_v == 0), "extent failure"); static_assert((extent_v == 0), "extent failure"); static_assert((extent_v == 4), "extent failure"); static_assert((extent_v == 4), "extent failure"); // is_aligned static_assert(is_aligned::value == false, "is_aligned failure"); EATEST_VERIFY(GetType(is_aligned()) == false); static_assert(is_aligned::value == false, "is_aligned failure"); EATEST_VERIFY(GetType(is_aligned()) == false); static_assert(is_aligned::value == false, "is_aligned failure"); EATEST_VERIFY(GetType(is_aligned()) == false); static_assert(is_aligned::value == false, "is_aligned failure"); EATEST_VERIFY(GetType(is_aligned()) == false); static_assert(is_aligned::value == false, "is_aligned failure"); EATEST_VERIFY(GetType(is_aligned()) == false); { #if (kEASTLTestAlign16 == 16) // To do: Rename kEASTLTestAlign16, as what it really means is "is 16 byte alignment+ supported". static_assert(is_aligned::value, "is_aligned failure"); EATEST_VERIFY(GetType(is_aligned())); static_assert(is_aligned::value, "is_aligned failure"); EATEST_VERIFY(GetType(is_aligned())); static_assert(is_aligned::value, "is_aligned failure"); EATEST_VERIFY(GetType(is_aligned())); #endif } // is_same static_assert((is_same::value == true), "is_same failure"); static_assert((is_same::value == true), "is_same failure"); static_assert((is_same::value == true), "is_same failure"); static_assert((is_same::value == true), "is_same failure"); static_assert((is_same::value == true), "is_same failure"); static_assert((is_same::value == false), "is_same failure"); static_assert((is_same::value == false), "is_same failure"); static_assert((is_same_v == true), "is_same_v failure"); static_assert((is_same_v == true), "is_same_v failure"); static_assert((is_same_v == true), "is_same_v failure"); static_assert((is_same_v == true), "is_same_v failure"); static_assert((is_same_v == true), "is_same_v failure"); static_assert((is_same_v == false), "is_same_v failure"); static_assert((is_same_v == false), "is_same_v failure"); // is_convertible static_assert((is_convertible::value == true), "is_convertible failure"); static_assert((is_convertible::value == true), "is_convertible failure"); // This is a conversion from 32 bits down to 16 bits. All compilers natively report that this is true. However, VC++ generates warnings for actual such conversions. static_assert((is_convertible::value == true), "is_convertible failure"); static_assert((is_convertible::value == true), "is_convertible failure"); static_assert((is_convertible::value == true), "is_convertible failure"); static_assert((is_convertible::value == false), "is_convertible failure"); static_assert((is_convertible::value == true), "is_convertible failure"); static_assert((is_convertible::value == false), "is_convertible failure"); #if EASTL_TYPE_TRAIT_is_convertible_CONFORMANCE // This causes compile failures. static_assert((is_convertible::value == false), "is_convertible failure"); #endif // Test EASTL_DECLARE_TRIVIAL_ASSIGN(HiddenAssign); eastl::vector v; EATEST_VERIFY(v.empty()); // make_signed // make_unsigned { // Test declarations eastl::make_signed::type i8 = -1; EATEST_VERIFY(i8 == -1); eastl::make_unsigned::type u8 = 0xff; EATEST_VERIFY(u8 == 0xff); eastl::make_signed::type i16 = -1; EATEST_VERIFY(i16 == -1); eastl::make_unsigned::type u16 = 0xffff; EATEST_VERIFY(u16 == 0xffff); eastl::make_signed::type i32 = -1; EATEST_VERIFY(i32 == -1); eastl::make_unsigned::type u32 = 0xffffffff; EATEST_VERIFY(u32 == 0xffffffff); eastl::make_signed::type i64 = -1; EATEST_VERIFY(i64 == -1); eastl::make_unsigned::type u64 = UINT64_C(0xffffffffffffffff); EATEST_VERIFY(u64 == UINT64_C(0xffffffffffffffff)); // Test conversions via static_cast: u8 = static_cast::type>(i8); EATEST_VERIFY(u8 == 0xff); i8 = static_cast::type>(u8); EATEST_VERIFY(i8 == -1); u16 = static_cast::type>(i16); EATEST_VERIFY(u16 == 0xffff); i16 = static_cast::type>(u16); EATEST_VERIFY(i16 == -1); u32 = static_cast::type>(i32); EATEST_VERIFY(u32 == 0xffffffff); i32 = static_cast::type>(u32); EATEST_VERIFY(i32 == -1); u64 = static_cast::type>(i64); EATEST_VERIFY(u64 == UINT64_C(0xffffffffffffffff)); i64 = static_cast::type>(u64); EATEST_VERIFY(i64 == -1); } // remove_const // remove_volatile // remove_cv { // To do: Make more thorough tests verifying this. Such tests will probably involve template metaprogramming. remove_const::type i32 = 47; EATEST_VERIFY(++i32 == 48); remove_volatile::type i16 = 47; EATEST_VERIFY(++i16 == 48); remove_cv::type i64 = 47; EATEST_VERIFY(++i64 == 48); //static_assert(is_same::type , std::remove_cv::type>::value, "remove_cv failure"); } // remove_cvref { static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); static_assert(is_same_v, int>, "remove_cvref failure"); // test pointer types static_assert(is_same_v, int*>, "remove_cvref failure"); static_assert(is_same_v, int*>, "remove_cvref failure"); static_assert(is_same_v, int*>, "remove_cvref failure"); static_assert(is_same_v, const int*>, "remove_cvref failure"); static_assert(is_same_v, const int*>, "remove_cvref failure"); static_assert(is_same_v, const int*>, "remove_cvref failure"); static_assert(is_same_v, int*>, "remove_cvref failure"); static_assert(is_same_v, int*>, "remove_cvref failure"); static_assert(is_same_v, int*>, "remove_cvref failure"); static_assert(is_same_v, int*>, "remove_cvref failure"); static_assert(is_same_v, int*>, "remove_cvref failure"); static_assert(is_same_v, int*>, "remove_cvref failure"); } // add_const // add_volatile // add_cv { // To do: Make more thorough tests verifying this. Such tests will probably involve template metaprogramming. eastl::add_const::type i32 = 47; EATEST_VERIFY(i32 == 47); eastl::add_volatile::type i16 = 47; EATEST_VERIFY(++i16 == 48); eastl::add_cv::type i64 = 47; EATEST_VERIFY(i64 == 47); } // as_const { { int i = 42; static_assert(eastl::is_same::value, "expecting a 'const T&' return type"); EATEST_VERIFY(eastl::as_const(i) == 42); } { eastl::string str = "Electronic Arts"; static_assert(eastl::is_same::value, "expecting a 'const T&' return type"); EATEST_VERIFY(eastl::as_const(str) == "Electronic Arts"); } } // remove_reference // add_reference // remove_pointer // add_pointer // remove_extent // remove_all_extents { int x = 17; eastl::add_reference::type xRef = x; x++; EATEST_VERIFY(xRef == 18); eastl::remove_reference::type xValue; xValue = 3; EATEST_VERIFY(xValue == 3); eastl::add_pointer::type xPtr = &x; *xPtr = 19; EATEST_VERIFY(x == 19); eastl::remove_pointer::type yValue; yValue = 3; EATEST_VERIFY(yValue == 3); // remove_extent // If T is an array of some type X, provides the member typedef type equal to X, otherwise // type is T. Note that if T is a multidimensional array, only the first dimension is removed. typedef int IntArray1[37]; typedef eastl::remove_extent::type Int; static_assert((eastl::is_same::value == true), "remove_extent/is_same failure"); // remove_all_extents typedef int IntArray2[37][54]; typedef eastl::remove_all_extents::type Int2; static_assert((eastl::is_same::value == true), "remove_all_extents/is_same failure"); } // decay { static_assert((eastl::is_same::type>::value == true), "is_same failure"); static_assert((eastl::is_same::type>::value == true), "is_same failure"); static_assert((eastl::is_same::type>::value == true), "is_same failure"); static_assert((eastl::is_same::type>::value == true), "is_same failure"); static_assert((eastl::is_same::type>::value == true), "is_same failure"); static_assert((eastl::is_same::type>::value == true), "is_same failure"); #if !EASTL_NO_RVALUE_REFERENCES static_assert((eastl::is_same::type>::value == true), "is_same failure"); #endif static_assert((eastl::is_same::type>::value == true), "is_same failure"); static_assert((eastl::is_same::type>::value == true), "is_same failure"); } // aligned_storage // Some compilers don't support or ignore alignment specifications for stack variables, // so we limit our testing to compilers that are known to support it. #if (EA_ALIGN_MAX_AUTOMATIC >= 64) && defined(EA_PLATFORM_DESKTOP) // Actually there are additional compilers that support alignment of stack-based variables, most significantly clang, GCC 4.4+, and probably others. { // Test the creation of a single aligned value. const size_t kArraySize = 100; const size_t kExpectedAlignment = 64; typedef uint16_t Type; eastl::aligned_storage::type data; Type* value = new(&data) Type; *value = 37; EATEST_VERIFY_F((EA::StdC::GetAlignment(value) >= kExpectedAlignment) && (*value == 37), "eastl::aligned_storage failure: Expected: %u, Actual: %u", (unsigned)kExpectedAlignment, (unsigned)EA::StdC::GetAlignment(value)); // Create an array of 100 values aligned. eastl::aligned_storage::type dataArray[kArraySize]; Type* valueArray = new(dataArray) Type[kArraySize]; valueArray[0] = 37; EATEST_VERIFY_F((EA::StdC::GetAlignment(valueArray) >= kExpectedAlignment) && (valueArray[0] == 37), "eastl::aligned_storage failure: Expected: %u, Actual: %u", (unsigned)kExpectedAlignment, (unsigned)EA::StdC::GetAlignment(valueArray)); } { // Test the creation of a single aligned value. const size_t kArraySize = 17; const size_t kExpectedAlignment = 128; typedef uint8_t Type; eastl::aligned_storage::type data; Type* value = new(&data) Type; *value = 37; EATEST_VERIFY_F((EA::StdC::GetAlignment(value) >= kExpectedAlignment) && (*value == 37), "eastl::aligned_storage failure: Expected: %u, Actual: %u", (unsigned)kExpectedAlignment, (unsigned)EA::StdC::GetAlignment(value)); // Create an array of 100 values aligned. eastl::aligned_storage::type dataArray[kArraySize]; Type* valueArray = new(dataArray) Type[kArraySize]; valueArray[0] = 37; EATEST_VERIFY_F((EA::StdC::GetAlignment(valueArray) >= kExpectedAlignment) && (valueArray[0] == 37), "eastl::aligned_storage failure: Expected: %u, Actual: %u", (unsigned)kExpectedAlignment, (unsigned)EA::StdC::GetAlignment(valueArray)); } { // Test the creation of a single aligned value. const size_t kArraySize = 27; const size_t kExpectedAlignment = 256; typedef uint32_t Type; eastl::aligned_storage::type data; Type* value = new(&data) Type; *value = 37; EATEST_VERIFY_F((EA::StdC::GetAlignment(value) >= kExpectedAlignment) && (*value == 37), "eastl::aligned_storage failure: Expected: %u, Actual: %u", (unsigned)kExpectedAlignment, (unsigned)EA::StdC::GetAlignment(value)); // Create an array of 100 values aligned. eastl::aligned_storage::type dataArray[kArraySize]; Type* valueArray = new(dataArray) Type[kArraySize]; valueArray[0] = 37; EATEST_VERIFY_F((EA::StdC::GetAlignment(valueArray) >= kExpectedAlignment) && (valueArray[0] == 37), "eastl::aligned_storage failure: Expected: %u, Actual: %u", (unsigned)kExpectedAlignment, (unsigned)EA::StdC::GetAlignment(valueArray)); } #endif // aligned_union // Some compilers don't support or ignore alignment specifications for stack variables, // so we limit our testing to compilers that are known to support it. { union AlignedUnion { char c; int i; float f; char a[32]; AlignedUnion(float fValue) : f(fValue) {} }; typedef aligned_union::type AlignedUnionStorage; static_assert((EA_ALIGN_OF(AlignedUnionStorage) >= EA_ALIGN_OF(float)) && (EA_ALIGN_OF(AlignedUnionStorage) <= EA_ALIGN_OF(double)), "aligned_union failure"); static_assert(sizeof(AlignedUnionStorage) >= sizeof(AlignedUnion), "aligned_union failure"); AlignedUnionStorage alignedUnionStorage; // Since we know that our alignment is a simple value <= default alignment, we can just declare an object here and it will work with all compilers, including those that are limited in the stack alignments they support. AlignedUnion* pAlignedUnion = new (&alignedUnionStorage) AlignedUnion(21.4f); EATEST_VERIFY(pAlignedUnion->f == 21.4f); pAlignedUnion->i = 37; EATEST_VERIFY(pAlignedUnion->i == 37); } // union_cast { float f32 = -1234.f; uint32_t n32 = union_cast(f32); float f32New = union_cast(n32); EATEST_VERIFY(f32 == f32New); double f64 = -1234.0; uint64_t n64 = union_cast(f64); double f64New = union_cast(n64); EATEST_VERIFY(f64 == f64New); PodA a = { -1234 }; PodB b = union_cast(a); PodA aNew = union_cast(b); EATEST_VERIFY(a == aNew); PodA* pA = new PodA; PodB* pB = union_cast(pA); PodA* pANew = union_cast(pB); EATEST_VERIFY(pA == pANew); delete pA; } // void_t #if EASTL_VARIABLE_TEMPLATES_ENABLED { { static_assert(is_same_v, void>, "void_t failure"); static_assert(is_same_v, void>, "void_t failure"); static_assert(is_same_v, void>, "void_t failure"); static_assert(is_same_v, void>, "void_t failure"); static_assert(is_same_v, void>, "void_t failure"); static_assert(is_same_v, void>, "void_t failure"); static_assert(is_same_v, void>, "void_t failure"); static_assert(is_same_v>, void>, "void_t failure"); } // new sfinae mechansim test { static_assert(has_increment_operator::value, "void_t sfinae failure"); static_assert(!has_increment_operator::value, "void_t sfinae failure"); } } #endif // conjunction { static_assert( conjunction<>::value, "conjunction failure"); static_assert(!conjunction::value, "conjunction failure"); static_assert(!conjunction::value, "conjunction failure"); static_assert(!conjunction::value, "conjunction failure"); static_assert(!conjunction::value, "conjunction failure"); static_assert(!conjunction::value, "conjunction failure"); static_assert(!conjunction::value, "conjunction failure"); static_assert(!conjunction::value, "conjunction failure"); static_assert(!conjunction::value, "conjunction failure"); static_assert( conjunction::value, "conjunction failure"); static_assert( conjunction::value, "conjunction failure"); static_assert( conjunction::value, "conjunction failure"); static_assert( conjunction::value, "conjunction failure"); #if EASTL_VARIABLE_TEMPLATES_ENABLED static_assert( conjunction_v<>, "conjunction failure"); static_assert(!conjunction_v, "conjunction failure"); static_assert(!conjunction_v, "conjunction failure"); static_assert(!conjunction_v, "conjunction failure"); static_assert(!conjunction_v, "conjunction failure"); static_assert(!conjunction_v, "conjunction failure"); static_assert(!conjunction_v, "conjunction failure"); static_assert(!conjunction_v, "conjunction failure"); static_assert(!conjunction_v, "conjunction failure"); static_assert( conjunction_v, "conjunction failure"); static_assert( conjunction_v, "conjunction failure"); static_assert( conjunction_v, "conjunction failure"); static_assert( conjunction_v, "conjunction failure"); #endif } // disjunction { static_assert(!disjunction<>::value, "disjunction failure"); static_assert(!disjunction::value, "disjunction failure"); static_assert(!disjunction::value, "disjunction failure"); static_assert(!disjunction::value, "disjunction failure"); static_assert( disjunction::value, "disjunction failure"); static_assert( disjunction::value, "disjunction failure"); static_assert( disjunction::value, "disjunction failure"); static_assert( disjunction::value, "disjunction failure"); static_assert( disjunction::value, "disjunction failure"); static_assert( disjunction::value, "disjunction failure"); static_assert( disjunction::value, "disjunction failure"); static_assert( disjunction::value, "disjunction failure"); static_assert( disjunction::value, "disjunction failure"); #if EASTL_VARIABLE_TEMPLATES_ENABLED static_assert(!disjunction_v<>, "disjunction failure"); static_assert(!disjunction_v, "disjunction failure"); static_assert(!disjunction_v, "disjunction failure"); static_assert(!disjunction_v, "disjunction failure"); static_assert( disjunction_v, "disjunction failure"); static_assert( disjunction_v, "disjunction failure"); static_assert( disjunction_v, "disjunction failure"); static_assert( disjunction_v, "disjunction failure"); static_assert( disjunction_v, "disjunction failure"); static_assert( disjunction_v, "disjunction failure"); static_assert( disjunction_v, "disjunction failure"); static_assert( disjunction_v, "disjunction failure"); static_assert( disjunction_v, "disjunction failure"); #endif } // negation { static_assert( negation::value, "negation failure"); static_assert(!negation::value, "negation failure"); #if EASTL_VARIABLE_TEMPLATES_ENABLED static_assert( negation_v, "negation failure"); static_assert(!negation_v, "negation failure"); #endif } // has_unique_object_representations { static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); static_assert(!has_unique_object_representations::value, "has_unique_object_representations failure"); #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type which is already handled... static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); #endif #if EASTL_TYPE_TRAIT_has_unique_object_representations_CONFORMANCE { struct packed_type { int a; }; static_assert( has_unique_object_representations::value, "has_unique_object_representations failure"); struct padded_type { int a; char b; int c; }; static_assert(!has_unique_object_representations::value, "has_unique_object_representations failure"); } #endif } // is_final { #if (EA_COMPILER_HAS_FEATURE(is_final)) static_assert(std::is_final::value == eastl::is_final::value, "final struct not correctly detected"); static_assert(std::is_final::value == eastl::is_final::value, "final class not correctly detected"); static_assert(std::is_final::value == eastl::is_final::value, "enum not correctly detected"); static_assert(std::is_final::value == eastl::is_final::value, "int not correctly detected"); static_assert(std::is_final::value == eastl::is_final::value, "non-final struct not correctly detected"); static_assert(std::is_final::value == eastl::is_final::value, "non-final class not correctly detected"); #endif // endian (big-endian and little; no mixed-endian/middle-endian) static_assert(eastl::endian::big != eastl::endian::little, "little-endian and big-endian are not the same"); static_assert(eastl::endian::native == eastl::endian::big || eastl::endian::native == eastl::endian::little, "native may be little endian or big endian"); static_assert(!(eastl::endian::native == eastl::endian::big && eastl::endian::native == eastl::endian::little), "native cannot be both big and little endian"); #ifdef EA_SYSTEM_LITTLE_ENDIAN static_assert(eastl::endian::native == eastl::endian::little, "must be little endian"); static_assert(eastl::endian::native != eastl::endian::big, "must not be big endian"); #else static_assert(eastl::endian::native != eastl::endian::little, "must not be little endian"); static_assert(eastl::endian::native == eastl::endian::big, "must be big endian"); #endif } // has_equality { static_assert( has_equality_v, "has_equality failure"); static_assert( has_equality_v, "has_equality failure"); static_assert( has_equality_v, "has_equality failure"); static_assert( has_equality_v, "has_equality failure"); static_assert( has_equality_v, "has_equality failure"); static_assert(!has_equality_v, "has_equality failure"); } // is_aggregate #if EASTL_TYPE_TRAIT_is_aggregate_CONFORMANCE { static_assert(!is_aggregate_v, "is_aggregate failure"); static_assert( is_aggregate_v, "is_aggregate failure"); { struct Aggregrate {}; static_assert(is_aggregate_v, "is_aggregate failure"); } { struct NotAggregrate { NotAggregrate() {} }; // user provided ctor static_assert(!is_aggregate_v, "is_aggregate failure"); } #ifndef EA_COMPILER_MSVC // NOTE(rparolin): MSVC is incorrectly categorizing the aggregate type in this test-case. { struct NotAggregrate { int data = 42; }; // default member initializer static_assert(!is_aggregate_v, "is_aggregate failure"); } #endif { struct NotAggregrate { virtual void foo() {} }; // virtual member function static_assert(!is_aggregate_v, "is_aggregate failure"); } } #endif return nErrorCount; }