From f54563ef071b72adf7dccefb1d0233ae982e1052 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 10 Jan 2020 13:27:05 +0000 Subject: [PATCH] Added use of C++11's 'alignof' keyword in 'alignment_of', if available --- include/etl/type_traits.h | 14 ++++++++------ include/etl/type_traits_generator.h | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 617b2f75..f1fdbc58 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -718,7 +718,9 @@ namespace etl //*************************************************************************** /// Alignment templates. /// These require compiler specific intrinsics. -#ifdef ETL_COMPILER_MICROSOFT +#if ETL_CPP11_SUPPORTED + template struct alignment_of : integral_constant { }; +#elif ETL_COMPILER_MICROSOFT template struct alignment_of : integral_constant {}; #elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI) template struct alignment_of : integral_constant {}; @@ -1304,7 +1306,7 @@ namespace etl struct is_one_of { static const bool value = etl::is_same::value || - etl::is_one_of::value; + etl::is_one_of::value; }; template @@ -1317,13 +1319,13 @@ namespace etl /// Template to determine if a type is one of a specified list. ///\ingroup types template struct is_one_of { - static const bool value = + static const bool value = etlstd::is_same::value || etlstd::is_same::value || etlstd::is_same::value || diff --git a/include/etl/type_traits_generator.h b/include/etl/type_traits_generator.h index 78a42254..e1ebc66b 100644 --- a/include/etl/type_traits_generator.h +++ b/include/etl/type_traits_generator.h @@ -730,7 +730,9 @@ namespace etl //*************************************************************************** /// Alignment templates. /// These require compiler specific intrinsics. -#ifdef ETL_COMPILER_MICROSOFT +#if ETL_CPP11_SUPPORTED + template struct alignment_of : integral_constant { }; +#elif ETL_COMPILER_MICROSOFT template struct alignment_of : integral_constant {}; #elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI) template struct alignment_of : integral_constant {};