diff --git a/library.properties b/library.properties index 844ae5f1..3ad9dba9 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=9.1.5 +version=9.1.6 author= John Wellbelove maintainer=John Wellbelove sentence=A C++ template library tailored for embedded systems. diff --git a/src/platform.h b/src/platform.h index a9c3efee..5a2caf98 100644 --- a/src/platform.h +++ b/src/platform.h @@ -80,18 +80,25 @@ SOFTWARE. // Check to see if the compiler supports static_assert. #if (defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER >= 1600)) || \ (defined(ETL_COMPILER_GCC) && (__cplusplus >= 201103L)) -#define ETL_STATIC_ASSERT_SUPPORTED + #define ETL_STATIC_ASSERT_SUPPORTED #endif // Check to see if the compiler supports C++11 type traits. #if (defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER >= 1600)) || \ (defined(ETL_COMPILER_GCC) && (__cplusplus >= 201103L)) -#define ETL_C11_TYPE_TRAITS_SUPPORTED + #define ETL_C11_TYPE_TRAITS_SUPPORTED #endif +// Check to see if the compiler supports C++11 'is_trivially_xxx' traits. #if (defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER >= 1600)) || \ (defined(ETL_COMPILER_GCC) && (__cplusplus >= 201402L)) -#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + #define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED +#endif + +// Check to see if the compiler supports C++11 'alignof'. +#if (defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER >= 1600)) || \ + (defined(ETL_COMPILER_GCC) && (__cplusplus >= 201103L)) + #define ETL_C11_ALIGNOF_SUPPORTED #endif // Some targets do not support 8bit types. diff --git a/src/type_traits.h b/src/type_traits.h index 453423d0..5c9876a5 100644 --- a/src/type_traits.h +++ b/src/type_traits.h @@ -36,6 +36,10 @@ SOFTWARE. #include "platform.h" #include "nullptr.h" +#if defined(ETL_C11_TYPE_TRAITS_SUPPORTED) + #include +#endif + ///\defgroup type_traits type_traits /// A set of type traits definitions for compilers that do not support the standard header. /// \ingroup utilities @@ -233,11 +237,38 @@ namespace etl template struct is_reference : true_type {}; /// is_pod - /// For C++03, only fundamental and pointers types are recognised. ///\ingroup type_traits + +#if defined(ETL_C11_TYPE_TRAITS_SUPPORTED)// && !defined(ETL_IN_UNIT_TEST) + // For compilers that support C++11 + template struct is_pod : std::is_pod {}; +#else + /// For C++03, only fundamental and pointers types are recognised. template struct is_pod : etl::integral_constant::value || etl::is_pointer::value> {}; +#endif +#if defined(ETL_C11_TYPE_TRAITS_SUPPORTED) && defined(ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED)// && !defined(ETL_IN_UNIT_TEST) + /// is_trivially_constructible + /// For C++03, only POD types are recognised. + ///\ingroup type_traits + template struct is_trivially_constructible : std::is_trivially_constructible {}; + + /// is_trivially_copy_constructible + /// For C++03, only POD types are recognised. + ///\ingroup type_traits + template struct is_trivially_copy_constructible : std::is_trivially_copy_constructible {}; + + /// is_trivially_destructible + /// For C++03, only POD types are recognised. + ///\ingroup type_traits + template struct is_trivially_destructible : std::is_trivially_destructible {}; + + /// is_trivially_copy_assignable + /// For C++03, only POD types are recognised. + ///\ingroup type_traits + template struct is_trivially_copy_assignable : std::is_trivially_copy_assignable {}; +#else /// is_trivially_constructible /// For C++03, only POD types are recognised. ///\ingroup type_traits @@ -257,6 +288,7 @@ namespace etl /// For C++03, only POD types are recognised. ///\ingroup type_traits template struct is_trivially_copy_assignable : etl::is_pod {}; +#endif /// conditional ///\ingroup type_traits @@ -363,24 +395,21 @@ namespace etl /// Alignment templates. /// These require compiler specific intrinsics. ///\ingroup type_traits -#ifdef ETL_COMPILER_MICROSOFT +#if defined(ETL_C11_ALIGNOF_SUPPORTED) + template struct alignment_of : integral_constant {}; +#elif defined(ETL_COMPILER_MICROSOFT) template struct alignment_of : integral_constant {}; -#endif - -#ifdef ETL_COMPILER_GCC +#elif defined(ETL_COMPILER_GCC) template struct alignment_of : integral_constant {}; -#endif - -#ifdef ETL_COMPILER_KEIL +#elif defined(ETL_COMPILER_KEIL) template struct alignment_of : integral_constant {}; -#endif - -#ifdef ETL_COMPILER_IAR +#elif defined(ETL_COMPILER_IAR) template struct alignment_of : integral_constant {}; -#endif - -#ifdef ETL_COMPILER_TI +#elif defined(ETL_COMPILER_TI) template struct alignment_of : integral_constant {}; +#else + // Best guess! + template struct alignment_of : integral_constant {}; #endif /// Specialisation of 'alignment_of' for 'void'.