From e109e4977b9a5edbbcc0e8bd34c04b2bd8fc5c68 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 24 Jun 2021 20:38:57 +0100 Subject: [PATCH] C++20 compatibility for deprecated std::is_pod --- .../etl/generators/type_traits_generator.h | 30 +++++++++++++++---- include/etl/type_traits.h | 30 +++++++++++++++---- include/etl/vector.h | 4 --- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 776d991b..b2d405fe 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -1148,51 +1148,71 @@ namespace etl //*************************************************************************** /// is_trivially_constructible ///\ingroup type_traits +#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template struct is_trivially_constructible : std::is_trivially_constructible {}; +#else template struct is_trivially_constructible : std::is_pod {}; +#endif #if ETL_CPP17_SUPPORTED template - inline constexpr bool is_trivially_constructible_v = std::is_pod_v; + inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible::value; #endif //*************************************************************************** /// is_trivially_copy_constructible ///\ingroup type_traits +#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template struct is_trivially_copy_constructible : std::is_trivially_copy_constructible {}; +#else template struct is_trivially_copy_constructible : std::is_pod {}; +#endif #if ETL_CPP17_SUPPORTED template - inline constexpr bool is_trivially_copy_constructible_v = std::is_pod_v; + inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible::value; #endif //*************************************************************************** /// is_trivially_destructible ///\ingroup type_traits +#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template struct is_trivially_destructible : std::is_trivially_destructible {}; +#else template struct is_trivially_destructible : std::is_pod {}; +#endif #if ETL_CPP17_SUPPORTED template - inline constexpr bool is_trivially_destructible_v = std::is_pod_v; + inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible::value; #endif //*************************************************************************** /// is_trivially_copy_assignable ///\ingroup type_traits +#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template struct is_trivially_copy_assignable : std::is_trivially_copy_assignable {}; +#else template struct is_trivially_copy_assignable : std::is_pod {}; +#endif #if ETL_CPP17_SUPPORTED template - inline constexpr bool is_trivially_copy_assignable_v = std::is_pod_v; + inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable::value; #endif //*************************************************************************** /// is_trivially_copyable ///\ingroup type_traits +#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template struct is_trivially_copyable : std::is_trivially_copyable {}; +#else template struct is_trivially_copyable : std::is_pod {}; +#endif #if ETL_CPP17_SUPPORTED template - inline constexpr bool is_trivially_copyable_v = std::is_pod_v; + inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; #endif #endif diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index e51a839e..281b94bf 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -1136,51 +1136,71 @@ namespace etl //*************************************************************************** /// is_trivially_constructible ///\ingroup type_traits +#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template struct is_trivially_constructible : std::is_trivially_constructible {}; +#else template struct is_trivially_constructible : std::is_pod {}; +#endif #if ETL_CPP17_SUPPORTED template - inline constexpr bool is_trivially_constructible_v = std::is_pod_v; + inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible::value; #endif //*************************************************************************** /// is_trivially_copy_constructible ///\ingroup type_traits +#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template struct is_trivially_copy_constructible : std::is_trivially_copy_constructible {}; +#else template struct is_trivially_copy_constructible : std::is_pod {}; +#endif #if ETL_CPP17_SUPPORTED template - inline constexpr bool is_trivially_copy_constructible_v = std::is_pod_v; + inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible::value; #endif //*************************************************************************** /// is_trivially_destructible ///\ingroup type_traits +#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template struct is_trivially_destructible : std::is_trivially_destructible {}; +#else template struct is_trivially_destructible : std::is_pod {}; +#endif #if ETL_CPP17_SUPPORTED template - inline constexpr bool is_trivially_destructible_v = std::is_pod_v; + inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible::value; #endif //*************************************************************************** /// is_trivially_copy_assignable ///\ingroup type_traits +#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template struct is_trivially_copy_assignable : std::is_trivially_copy_assignable {}; +#else template struct is_trivially_copy_assignable : std::is_pod {}; +#endif #if ETL_CPP17_SUPPORTED template - inline constexpr bool is_trivially_copy_assignable_v = std::is_pod_v; + inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable::value; #endif //*************************************************************************** /// is_trivially_copyable ///\ingroup type_traits +#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template struct is_trivially_copyable : std::is_trivially_copyable {}; +#else template struct is_trivially_copyable : std::is_pod {}; +#endif #if ETL_CPP17_SUPPORTED template - inline constexpr bool is_trivially_copyable_v = std::is_pod_v; + inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; #endif #endif diff --git a/include/etl/vector.h b/include/etl/vector.h index b1ee244c..81ce56e3 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -1297,9 +1297,7 @@ namespace etl ETL_OVERRIDE #endif { - #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_ASSERT(etl::is_trivially_copyable::value, ETL_ERROR(etl::vector_incompatible_type)); - #endif etl::ivector::repair_buffer(buffer); } @@ -1468,9 +1466,7 @@ namespace etl ETL_OVERRIDE #endif { -#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_ASSERT(etl::is_trivially_copyable::value, ETL_ERROR(etl::vector_incompatible_type)); -#endif etl::ivector::repair_buffer(this->p_buffer); }