diff --git a/UNITTESTS/target_h/platform/cxxsupport/mstd_type_traits b/UNITTESTS/target_h/platform/cxxsupport/mstd_type_traits index b1c069b8f6..0513ba91f3 100644 --- a/UNITTESTS/target_h/platform/cxxsupport/mstd_type_traits +++ b/UNITTESTS/target_h/platform/cxxsupport/mstd_type_traits @@ -20,26 +20,6 @@ /* * * - includes toolchain's - * - For ARM C 5, standard C++11/14 features: - * - std::integral_constant, std::true_type, std::false_type - * - primary type categories (std::is_void, std::is_integral etc) - * - composite type categories (std::is_reference etc) - * - type properties (std::is_const, std::is_constructible etc), except std::is_final - * - type property queries (std::alignment_of, std::rank, std::extent) - * - type relations (std::is_same, std::is_base_of, std::is_convertible) - * - const-volatile modifications (std::remove_cv, std::add_const etc) - * - reference modifications (std::remove_reference, std::add_lvalue_reference etc) - * - sign modifications (std::make_signed, std::make_unsigned) - * - array modifications (std::remove_extent, std::remove_all_extents) - * - pointer modifications (std::remove_pointer, std::add_pointer) - * - other modifications: - * - std::aligned_storage - * - std::decay - * - std::enable_if - * - std::conditional - * - std::common_type - * - std::underlying_type - * - std::result_of * - For all toolchains, C++17/20 backports: * - mstd::type_identity * - mstd::bool_constant @@ -47,6 +27,7 @@ * - mstd::is_invocable, mbed::is_invocable_r, etc * - mstd::invoke_result * - logical operator traits (mstd::conjunction, mstd::disjunction, mstd::negation) + * - mstd::is_constant_evaluated */ #include @@ -55,7 +36,6 @@ // The template stuff in here is too confusing for astyle // *INDENT-OFF* - namespace mstd { /* C++20 type identity */ @@ -92,6 +72,10 @@ template struct invoke_result; #endif +} // namespace mstd + +namespace mstd { + using std::is_same; using std::conditional; using std::conditional_t; @@ -462,8 +446,30 @@ struct is_nothrow_invocable_r : impl::is_invocable_r= 9 +#define MSTD_HAS_IS_CONSTANT_EVALUATED 1 + return __builtin_is_constant_evaluated(); +#else + return false; +#endif +} + +#if MSTD_HAS_IS_CONSTANT_EVALUATED +#define MSTD_CONSTEXPR_IF_HAS_IS_CONSTANT_EVALUATED constexpr +#else +#define MSTD_CONSTEXPR_IF_HAS_IS_CONSTANT_EVALUATED +#endif } // namespace mstd - #endif /* MSTD_TYPE_TRAITS_ */