From 6089142a0a2b81221ac56eaa35c025b60974169e Mon Sep 17 00:00:00 2001 From: Rob Parolin Date: Sat, 16 Mar 2019 16:59:40 -0700 Subject: [PATCH] 3.13.04 release --- include/EASTL/chrono.h | 6 +- include/EASTL/internal/config.h | 4 +- include/EASTL/internal/functional_base.h | 10 +- include/EASTL/internal/type_compound.h | 61 ++++- include/EASTL/internal/type_fundamental.h | 15 ++ include/EASTL/internal/type_pod.h | 33 ++- include/EASTL/internal/type_properties.h | 32 ++- include/EASTL/internal/type_transformations.h | 10 + include/EASTL/string_hash_map.h | 35 +-- include/EASTL/type_traits.h | 36 +++ test/packages/EABase/.gitlab-ci.yml | 11 +- .../EABase/include/Common/EABase/eahave.h | 2 +- .../EABase/include/Common/EABase/version.h | 4 +- test/source/TestStringHashMap.cpp | 65 ++++++ test/source/TestTypeTraits.cpp | 218 +++++++++++++----- 15 files changed, 437 insertions(+), 105 deletions(-) diff --git a/include/EASTL/chrono.h b/include/EASTL/chrono.h index e67df1e6..028c0f49 100644 --- a/include/EASTL/chrono.h +++ b/include/EASTL/chrono.h @@ -47,7 +47,7 @@ #if defined(EA_PLATFORM_MICROSOFT) && !defined(EA_PLATFORM_MINGW) #include -#elif defined(EA_PLATFORM_PS4) +#elif defined(EA_PLATFORM_SONY) #include #include #elif defined(EA_PLATFORM_APPLE) @@ -544,7 +544,7 @@ namespace chrono { #if defined(EA_PLATFORM_MICROSOFT) && !defined(EA_PLATFORM_MINGW) #define EASTL_NS_PER_TICK 1 - #elif defined EA_PLATFORM_PS4 + #elif defined EA_PLATFORM_SONY #define EASTL_NS_PER_TICK _XTIME_NSECS_PER_TICK #elif defined EA_PLATFORM_POSIX #define EASTL_NS_PER_TICK _XTIME_NSECS_PER_TICK @@ -585,7 +585,7 @@ namespace chrono static auto frequency = queryFrequency(); // cache cpu frequency on first call EA_RESTORE_VC_WARNING() return uint64_t(frequency * queryCounter()); - #elif defined EA_PLATFORM_PS4 + #elif defined EA_PLATFORM_SONY return sceKernelGetProcessTimeCounter(); #elif defined(EA_PLATFORM_APPLE) return mach_absolute_time(); diff --git a/include/EASTL/internal/config.h b/include/EASTL/internal/config.h index 79e1a1bc..6f6b9e83 100644 --- a/include/EASTL/internal/config.h +++ b/include/EASTL/internal/config.h @@ -89,8 +89,8 @@ /////////////////////////////////////////////////////////////////////////////// #ifndef EASTL_VERSION - #define EASTL_VERSION "3.13.03" - #define EASTL_VERSION_N 31303 + #define EASTL_VERSION "3.13.04" + #define EASTL_VERSION_N 31304 #endif diff --git a/include/EASTL/internal/functional_base.h b/include/EASTL/internal/functional_base.h index a3d19af4..669e5fc3 100644 --- a/include/EASTL/internal/functional_base.h +++ b/include/EASTL/internal/functional_base.h @@ -19,8 +19,8 @@ namespace eastl { // foward declaration for swap template - inline void swap(T& a, T& b) EA_NOEXCEPT_IF(eastl::is_nothrow_move_constructible::value && - eastl::is_nothrow_move_assignable::value); + inline void swap(T& a, T& b) + EA_NOEXCEPT_IF(eastl::is_nothrow_move_constructible::value&& eastl::is_nothrow_move_assignable::value); /// invoke @@ -40,10 +40,8 @@ namespace eastl /// template auto invoke_impl(R C::*func, T&& obj, Args&&... args) -> - typename enable_if< - is_base_of>::value, - decltype((eastl::forward(obj).*func)(eastl::forward(args)...)) - >::type + typename enable_if>::value, + decltype((eastl::forward(obj).*func)(eastl::forward(args)...))>::type { return (eastl::forward(obj).*func)(eastl::forward(args)...); } diff --git a/include/EASTL/internal/type_compound.h b/include/EASTL/internal/type_compound.h index fddf72f3..178a7342 100644 --- a/include/EASTL/internal/type_compound.h +++ b/include/EASTL/internal/type_compound.h @@ -54,6 +54,11 @@ namespace eastl template // extent uses unsigned instead of size_t. struct extent : public eastl::extent_help { }; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR auto extent_v = extent::value; + #endif + /////////////////////////////////////////////////////////////////////// // is_array @@ -324,13 +329,25 @@ namespace eastl #endif - #if !defined(EA_COMPILER_NO_TEMPLATE_ALIASES) template EA_CONSTEXPR bool is_convertible_v = is_convertible::value; #endif + /////////////////////////////////////////////////////////////////////// + // is_nothrow_convertible + // + // https://en.cppreference.com/w/cpp/types/is_convertible + // + // template + // struct is_explicitly_convertible + // : public is_constructible {}; + /////////////////////////////////////////////////////////////////////// + // TODO(rparolin): implement type-trait + + + /////////////////////////////////////////////////////////////////////// // is_explicitly_convertible // @@ -367,6 +384,10 @@ namespace eastl #define EASTL_DECLARE_UNION(T) namespace eastl{ template <> struct is_union : public true_type{}; template <> struct is_union : public true_type{}; } + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_union_v = is_union::value; + #endif @@ -724,7 +745,7 @@ namespace eastl template struct is_final : public integral_constant {}; #else - // compiler support so we always return false + // no compiler support so we always return false template struct is_final : public false_type {}; #endif @@ -733,6 +754,42 @@ namespace eastl template EA_CONSTEXPR bool is_final_v = is_final::value; #endif + + + /////////////////////////////////////////////////////////////////////// + // is_aggregate + // + // https://en.cppreference.com/w/cpp/language/aggregate_initialization + // + // An aggregate is one of the following types: + // * array type + // * class type (typically, struct or union), that has + // * no private or protected non-static data members + // * no user-provided constructors (explicitly defaulted or deleted constructors are allowed) + // * no user-provided, inherited, or explicit constructors + // * (explicitly defaulted or deleted constructors are allowed) + // * no virtual, private, or protected (since C++17) base classes + // * no virtual member functions + // * no default member initializers + // + /////////////////////////////////////////////////////////////////////// + #if EA_COMPILER_HAS_FEATURE(is_aggregate) || defined(_MSC_VER) && (_MSC_VER >= 1916) // VS2017 15.9+ + #define EASTL_TYPE_TRAIT_is_aggregate_CONFORMANCE 1 + + template + struct is_aggregate : public integral_constant {}; + #else + #define EASTL_TYPE_TRAIT_is_aggregate_CONFORMANCE 0 + + // no compiler support so we always return false + template + struct is_aggregate : public false_type {}; + #endif + + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_aggregate_v = is_aggregate::value; + #endif } // namespace eastl diff --git a/include/EASTL/internal/type_fundamental.h b/include/EASTL/internal/type_fundamental.h index b0536fe4..a90cb445 100644 --- a/include/EASTL/internal/type_fundamental.h +++ b/include/EASTL/internal/type_fundamental.h @@ -208,6 +208,11 @@ namespace eastl struct is_arithmetic : public integral_constant::value || is_floating_point::value> {}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_arithmetic_v = is_arithmetic::value; + #endif + /////////////////////////////////////////////////////////////////////// // is_fundamental @@ -225,6 +230,11 @@ namespace eastl struct is_fundamental : public bool_constant || is_integral_v || is_floating_point_v || is_null_pointer_v> {}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_fundamental_v = is_fundamental::value; + #endif + /////////////////////////////////////////////////////////////////////// // is_hat_type @@ -243,6 +253,11 @@ namespace eastl template struct is_hat_type : public eastl::is_hat_type_helper {}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_hat_type_v = is_hat_type::value; + #endif + } // namespace eastl diff --git a/include/EASTL/internal/type_pod.h b/include/EASTL/internal/type_pod.h index f000e527..8726a7e6 100644 --- a/include/EASTL/internal/type_pod.h +++ b/include/EASTL/internal/type_pod.h @@ -140,6 +140,11 @@ namespace eastl struct is_standard_layout : public eastl::integral_constant::value || is_scalar::value>{}; #endif + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_standard_layout_v = is_standard_layout::value; + #endif + #define EASTL_DECLARE_IS_STANDARD_LAYOUT(T, isStandardLayout) \ namespace eastl { \ template <> struct is_standard_layout : public eastl::integral_constant { }; \ @@ -536,6 +541,11 @@ namespace eastl struct has_virtual_destructor : public eastl::false_type{}; #endif + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool has_virtual_destructor_v = has_virtual_destructor::value; + #endif + #define EASTL_DECLARE_HAS_VIRTUAL_DESTRUCTOR(T, hasVirtualDestructor) \ namespace eastl { \ template <> struct has_virtual_destructor : public eastl::integral_constant { }; \ @@ -1145,6 +1155,13 @@ namespace eastl + /////////////////////////////////////////////////////////////////////// + // is_nothrow_default_constructible + /////////////////////////////////////////////////////////////////////// + // TODO(rparolin): implement type-trait + + + /////////////////////////////////////////////////////////////////////// // is_copy_constructible // @@ -1512,11 +1529,10 @@ namespace eastl template <> struct is_nothrow_assignable : public eastl::integral_constant { }; \ } - #if EASTL_VARIABLE_TEMPLATES_ENABLED template EA_CONSTEXPR bool is_nothrow_assignable_v = is_nothrow_assignable::value; - #endif + #endif @@ -1641,6 +1657,10 @@ namespace eastl : public eastl::is_trivially_assignable::type, typename eastl::add_rvalue_reference::type> {}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_trivially_move_assignable_v = is_trivially_move_assignable::value; + #endif /////////////////////////////////////////////////////////////////////// @@ -1880,6 +1900,11 @@ namespace eastl template <> struct is_nothrow_destructible { static const bool value = isNoThrowDestructible; }; \ } + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_nothrow_destructible_v = is_nothrow_destructible::value; + #endif + /////////////////////////////////////////////////////////////////////// @@ -1892,6 +1917,10 @@ namespace eastl struct is_nothrow_default_constructible : public eastl::is_nothrow_constructible {}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_nothrow_default_constructible_v = is_nothrow_default_constructible::value; + #endif /////////////////////////////////////////////////////////////////////// diff --git a/include/EASTL/internal/type_properties.h b/include/EASTL/internal/type_properties.h index 4b59dd87..5276f878 100644 --- a/include/EASTL/internal/type_properties.h +++ b/include/EASTL/internal/type_properties.h @@ -127,6 +127,10 @@ namespace eastl template struct is_signed : public eastl::is_signed_helper::type>{}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_signed_v = is_signed::value; + #endif #define EASTL_DECLARE_SIGNED(T) \ namespace eastl{ \ @@ -177,6 +181,11 @@ namespace eastl template struct is_unsigned : public eastl::is_unsigned_helper::type>{}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_unsigned_v = is_unsigned::value; + #endif + #define EASTL_DECLARE_UNSIGNED(T) \ namespace eastl{ \ template <> struct is_unsigned : public true_type{}; \ @@ -255,6 +264,11 @@ namespace eastl template struct rank : public eastl::integral_constant::value + 1> {}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR auto rank_v = rank::value; + #endif + /////////////////////////////////////////////////////////////////////// // is_base_of @@ -295,21 +309,25 @@ namespace eastl template struct is_lvalue_reference : public eastl::false_type {}; template struct is_lvalue_reference : public eastl::true_type {}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_lvalue_reference_v = is_lvalue_reference::value; + #endif + /////////////////////////////////////////////////////////////////////// // is_rvalue_reference // /////////////////////////////////////////////////////////////////////// - #if EASTL_NO_RVALUE_REFERENCES - #define EASTL_TYPE_TRAIT_is_rvalue_reference_CONFORMANCE 0 // Given that the compiler doesn't support rvalue references, maybe the conformance here should be 1, since the result of this is always correct. + #define EASTL_TYPE_TRAIT_is_rvalue_reference_CONFORMANCE 1 // is_rvalue_reference is conforming. - template struct is_rvalue_reference : public eastl::false_type {}; - #else - #define EASTL_TYPE_TRAIT_is_rvalue_reference_CONFORMANCE 1 // is_rvalue_reference is conforming. + template struct is_rvalue_reference : public eastl::false_type {}; + template struct is_rvalue_reference : public eastl::true_type {}; - template struct is_rvalue_reference : public eastl::false_type {}; - template struct is_rvalue_reference : public eastl::true_type {}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_rvalue_reference_v = is_rvalue_reference::value; #endif diff --git a/include/EASTL/internal/type_transformations.h b/include/EASTL/internal/type_transformations.h index bb3a5b0c..cffa65e5 100644 --- a/include/EASTL/internal/type_transformations.h +++ b/include/EASTL/internal/type_transformations.h @@ -157,6 +157,11 @@ namespace eastl #endif #endif + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + using make_signed_t = typename make_signed::type; + #endif + /////////////////////////////////////////////////////////////////////// // add_signed @@ -222,6 +227,11 @@ namespace eastl #endif #endif + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + using make_unsigned_t = typename make_unsigned::type; + #endif + /////////////////////////////////////////////////////////////////////// diff --git a/include/EASTL/string_hash_map.h b/include/EASTL/string_hash_map.h index 694a7675..8f90f305 100644 --- a/include/EASTL/string_hash_map.h +++ b/include/EASTL/string_hash_map.h @@ -25,7 +25,7 @@ class string_hash_map : public eastl::hash_map insert_or_assign(const char* key, const T& value); + iterator erase(const_iterator position); + size_type erase(const char* key); + mapped_type& operator[](const char* key); private: char* strduplicate(const char* str); // Not implemented right now - //insert_return_type insert(const value_type& value); - //iterator insert(iterator position, const value_type& value); - //reverse_iterator erase(reverse_iterator position); - //reverse_iterator erase(reverse_iterator first, reverse_iterator last); + // insert_return_type insert(const value_type& value); + // iterator insert(iterator position, const value_type& value); + // reverse_iterator erase(reverse_iterator position); + // reverse_iterator erase(reverse_iterator first, reverse_iterator last); }; - template string_hash_map::string_hash_map(const string_hash_map& src, const allocator_type& allocator) : base(allocator) { @@ -71,8 +71,7 @@ string_hash_map::~string_hash_map() } template -void -string_hash_map::clear() +void string_hash_map::clear() { allocator_type& allocator = base::base_type::get_allocator(); for (const_iterator i=base::base_type::begin(), e=base::base_type::end(); i!=e; ++i) @@ -81,8 +80,7 @@ string_hash_map::clear() } template -void -string_hash_map::clear(bool clearBuckets) +void string_hash_map::clear(bool clearBuckets) { allocator_type& allocator = base::base_type::get_allocator(); for (const_iterator i=base::base_type::begin(), e=base::base_type::end(); i!=e; ++i) @@ -123,6 +121,13 @@ string_hash_map::insert(const char* key, const T& return base::base_type::insert(eastl::make_pair(strduplicate(key), value)); } +template +eastl::pair::iterator, bool> +string_hash_map::insert_or_assign(const char* key, const T& value) +{ + return base::base_type::insert_or_assign(strduplicate(key), value); +} + template typename string_hash_map::iterator string_hash_map::erase(const_iterator position) diff --git a/include/EASTL/type_traits.h b/include/EASTL/type_traits.h index bb767279..a8129889 100644 --- a/include/EASTL/type_traits.h +++ b/include/EASTL/type_traits.h @@ -573,9 +573,36 @@ namespace eastl // Dinkumware has an identity, but adds a member function to it: // const T& operator()(const T& t) const{ return t; } // + // NOTE(rparolin): Use 'eastl::type_identity' it was included in the C++20 + // standard. This is a legacy EASTL type we continue to support for + // backwards compatibility. + // template struct identity { using type = T; }; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + using identity_t = typename identity::type; + #endif + + + /////////////////////////////////////////////////////////////////////// + // type_identity + // + // The purpose of this is typically to deal with non-deduced template + // contexts. See the C++11 Standard, 14.8.2.5 p5. + // Also: http://cppquiz.org/quiz/question/109?result=CE&answer=&did_answer=Answer + // + // https://en.cppreference.com/w/cpp/types/type_identity + // + template + struct type_identity { using type = T; }; + + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + using type_identity_t = typename type_identity::type; + #endif + /////////////////////////////////////////////////////////////////////// @@ -657,6 +684,10 @@ namespace eastl template struct is_reference : public eastl::false_type{}; template struct is_reference : public eastl::true_type{}; + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_reference_v = is_reference::value; + #endif /////////////////////////////////////////////////////////////////////// @@ -703,6 +734,11 @@ namespace eastl : public eastl::true_type {}; #endif + #if EASTL_VARIABLE_TEMPLATES_ENABLED + template + EA_CONSTEXPR bool is_function_v = is_function::value; + #endif + // The following remove utilities are defined here instead of in the headers // below because they are core utilits that many other type traits need. diff --git a/test/packages/EABase/.gitlab-ci.yml b/test/packages/EABase/.gitlab-ci.yml index e75c69e8..1b297724 100644 --- a/test/packages/EABase/.gitlab-ci.yml +++ b/test/packages/EABase/.gitlab-ci.yml @@ -1,14 +1,7 @@ image: registry.gitlab.ea.com/dre/automation/frostbite/framework-linux:7.19.01 - -before_script: - - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ea.com/foundation/foundation-ci-files.git ci-files - -debug: +build: script: + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ea.com/foundation/foundation-ci-files.git ci-files - mono $FRAMEWORK_HOME/bin/nant.exe -masterconfigfile:ci-files/dev.xml -buildroot:/br -D:config=unix64-clang-dev-debug test-run -debug-opt: - script: - mono $FRAMEWORK_HOME/bin/nant.exe -masterconfigfile:ci-files/dev.xml -buildroot:/br -D:config=unix64-clang-dev-debug-opt test-run -opt: - script: - mono $FRAMEWORK_HOME/bin/nant.exe -masterconfigfile:ci-files/dev.xml -buildroot:/br -D:config=unix64-clang-dev-opt test-run diff --git a/test/packages/EABase/include/Common/EABase/eahave.h b/test/packages/EABase/include/Common/EABase/eahave.h index e263af6f..c341f7aa 100644 --- a/test/packages/EABase/include/Common/EABase/eahave.h +++ b/test/packages/EABase/include/Common/EABase/eahave.h @@ -225,7 +225,7 @@ // #include #if !defined(EA_HAVE_SIGNAL_H) && !defined(EA_NO_HAVE_SIGNAL_H) - #if !defined(EA_PLATFORM_BSD) && !defined(EA_PLATFORM_SONY) + #if !defined(EA_PLATFORM_BSD) && !defined(EA_PLATFORM_SONY) && !defined(CS_UNDEFINED_STRING) #define EA_HAVE_SIGNAL_H 1 #else #define EA_NO_HAVE_SIGNAL_H 1 diff --git a/test/packages/EABase/include/Common/EABase/version.h b/test/packages/EABase/include/Common/EABase/version.h index 00c58938..b691b03b 100644 --- a/test/packages/EABase/include/Common/EABase/version.h +++ b/test/packages/EABase/include/Common/EABase/version.h @@ -29,8 +29,8 @@ /////////////////////////////////////////////////////////////////////////////// #ifndef EABASE_VERSION - #define EABASE_VERSION "2.09.02" - #define EABASE_VERSION_N 20902 + #define EABASE_VERSION "2.09.03" + #define EABASE_VERSION_N 20903 #endif #endif diff --git a/test/source/TestStringHashMap.cpp b/test/source/TestStringHashMap.cpp index db848dee..6c131733 100644 --- a/test/source/TestStringHashMap.cpp +++ b/test/source/TestStringHashMap.cpp @@ -215,5 +215,70 @@ int TestStringHashMap() } + // pair insert_or_assign(const char* key, const T& value); + { + { + string_hash_map m; + + m.insert_or_assign("hello", 0); + EATEST_VERIFY(m["hello"] == 0); + + m.insert_or_assign("hello", 42); + EATEST_VERIFY(m["hello"] == 42); + + m.insert_or_assign("hello", 43); + EATEST_VERIFY(m["hello"] == 43); + + m.insert_or_assign("hello", 1143); + EATEST_VERIFY(m["hello"] == 1143); + + EATEST_VERIFY(m.size() == 1); + m.clear(); + EATEST_VERIFY(m.size() == 0); + } + + { + string_hash_map m; + m.insert_or_assign("hello", 0); + m.insert_or_assign("hello2", 0); + + EATEST_VERIFY(m.size() == 2); + m.clear(); + EATEST_VERIFY(m.size() == 0); + } + + { + string_hash_map m; + m.insert_or_assign("hello", 0); + m.insert_or_assign("hello2", 0); + + EATEST_VERIFY(m.size() == 2); + m.clear(true); + EATEST_VERIFY(m.size() == 0); + } + + { + string_hash_map m; + m.insert_or_assign("hello", 0); + m.insert_or_assign("hello2", 0); + + EATEST_VERIFY(m.size() == 2); + m.clear(false); + EATEST_VERIFY(m.size() == 0); + } + + { + string_hash_map m; + + m.insert_or_assign("hello", TestObject(42)); + EATEST_VERIFY(m["hello"].mX == 42); + + m.insert_or_assign("hello", TestObject(43)); + EATEST_VERIFY(m["hello"].mX == 43); + + EATEST_VERIFY(m.size() == 1); + } + } + return nErrorCount; } diff --git a/test/source/TestTypeTraits.cpp b/test/source/TestTypeTraits.cpp index c4244567..0fb6280f 100644 --- a/test/source/TestTypeTraits.cpp +++ b/test/source/TestTypeTraits.cpp @@ -504,6 +504,13 @@ int TestTypeTraits() 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"); @@ -566,25 +573,32 @@ int TestTypeTraits() // 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"); @@ -644,24 +658,30 @@ int TestTypeTraits() #endif // is_enum - static_assert(is_enum::value == true, "is_enum failure"); + 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::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::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::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); @@ -683,19 +703,34 @@ int TestTypeTraits() // 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"); + 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. + 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 @@ -842,30 +877,39 @@ int TestTypeTraits() // 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); @@ -971,69 +1015,87 @@ int TestTypeTraits() // is_signed - static_assert(is_signed::value == true, "is_unsigned failure"); + 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_unsigned failure"); + 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_unsigned failure"); + 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_unsigned failure"); + 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_unsigned failure"); + 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_unsigned failure"); + 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::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::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::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::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::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::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"); - #if !EASTL_NO_RVALUE_REFERENCES - static_assert((is_lvalue_reference::value == false), "is_lvalue_reference failure"); - #endif - static_assert((is_lvalue_reference::value == false), "is_lvalue_reference failure"); - static_assert((is_lvalue_reference::value == true), "is_lvalue_reference failure"); - #if !EASTL_NO_RVALUE_REFERENCES - static_assert((is_lvalue_reference::value == false), "is_lvalue_reference failure"); - #endif + 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"); - #if !EASTL_NO_RVALUE_REFERENCES - static_assert((is_rvalue_reference::value == true), "is_rvalue_reference failure"); - #endif - static_assert((is_rvalue_reference::value == false), "is_rvalue_reference failure"); - static_assert((is_rvalue_reference::value == false), "is_rvalue_reference failure"); - #if !EASTL_NO_RVALUE_REFERENCES - static_assert((is_rvalue_reference::value == true), "is_rvalue_reference failure"); - #endif + 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 @@ -1369,6 +1431,11 @@ int TestTypeTraits() 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 @@ -1382,6 +1449,16 @@ int TestTypeTraits() 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 @@ -1424,15 +1501,13 @@ int TestTypeTraits() static_assert((is_same::value == false), "is_same failure"); static_assert((is_same::value == false), "is_same failure"); - #if EASTL_VARIABLE_TEMPLATES_ENABLED - 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"); - #endif + 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"); @@ -1921,6 +1996,37 @@ int TestTypeTraits() 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; }