From f5f93926c916b5e934517841236a7dfaee969929 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 21 Nov 2021 14:32:49 +0000 Subject: [PATCH] Fixes for Ubuntu 18 --- .github/workflows/gcc.yml | 2 +- include/etl/array.h | 4 +- include/etl/circular_buffer.h | 2 +- include/etl/forward_list.h | 4 +- .../etl/generators/type_traits_generator.h | 110 +++++++++++------- include/etl/indirect_vector.h | 13 ++- include/etl/list.h | 4 +- include/etl/vector.h | 8 +- 8 files changed, 95 insertions(+), 52 deletions(-) diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index 04e382bf..2448fc34 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -1,7 +1,7 @@ name: gcc on: push: - branches: [ master ] + branches: [ master, development ] pull_request: branches: [ master ] diff --git a/include/etl/array.h b/include/etl/array.h index 289e1d46..848d4912 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -566,7 +566,7 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template array(T...) -> array::type, sizeof...(T)>; #endif @@ -574,7 +574,7 @@ namespace etl //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST template constexpr auto make_array(TValues&&... values) -> etl::array { diff --git a/include/etl/circular_buffer.h b/include/etl/circular_buffer.h index 941951e5..db614ccd 100644 --- a/include/etl/circular_buffer.h +++ b/include/etl/circular_buffer.h @@ -1281,7 +1281,7 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template circular_buffer(T, Ts...) ->circular_buffer && ...), T>, 1U + sizeof...(Ts)>; diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 9609ecbc..6cfca525 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -1756,7 +1756,7 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template forward_list(T...) ->forward_list, sizeof...(T)>; #endif @@ -1764,7 +1764,7 @@ namespace etl //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST template constexpr auto make_forward_list(T... t) -> etl::forward_list, sizeof...(T)> { diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 1f4a2ef8..f4d5ef26 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -2024,60 +2024,92 @@ namespace etl #endif #if ETL_CPP11_SUPPORTED - // primary template (used for zero types) - template - struct common_type {}; + //********************************************* + // common_type + // Based on the sample implementation detailed on + // https://en.cppreference.com/w/cpp/types/common_type + //********************************************* +#if ETL_CPP11_SUPPORTED + //*********************************** + // Primary template + template + struct common_type + { + }; - //////// one type - template - struct common_type : common_type {}; + //*********************************** + // One type + template + struct common_type : common_type + { + }; - namespace detail { - template + namespace private_common_type + { + template using void_t = void; - template - using conditional_result_t = decltype(false ? std::declval() : std::declval()); + template + using conditional_result_t = decltype(false ? declval() : declval()); - template - struct decay_conditional_result {}; - template + template + struct decay_conditional_result + { + }; + + template struct decay_conditional_result>> - : std::decay> {}; + : etl::decay> + { + }; - template - struct common_type_2_impl : decay_conditional_result {}; + template + struct common_type_2_impl : decay_conditional_result + { + }; - // C++11 implementation: - // template - // struct common_type_2_impl {}; - - template + template struct common_type_2_impl>> - : decay_conditional_result {}; + : decay_conditional_result + { + }; } - //////// two types - template + //*********************************** + // Two types + template struct common_type - : std::conditional::type>::value&& - std::is_same::type>::value, - detail::common_type_2_impl, - common_type::type, - typename std::decay::type>>::type{}; + : etl::conditional::type>::value&& etl::is_same::type>::value, + private_common_type::common_type_2_impl, + common_type::type, + typename etl::decay::type>>::type + { + }; - //////// 3+ types - namespace detail { - template - struct common_type_multi_impl {}; - template - struct common_type_multi_impl::type>, T1, T2, R...> - : common_type::type, R...> {}; + //*********************************** + // Three or more types + namespace private_common_type + { + template + struct common_type_multi_impl + { + }; + + template + struct common_type_multi_impl::type>, T1, T2, TRest...> + : common_type::type, TRest...> + { + }; } - template - struct common_type - : detail::common_type_multi_impl {}; + template + struct common_type + : private_common_type::common_type_multi_impl + { + }; + + template + using common_type_t = typename common_type::type; #endif } diff --git a/include/etl/indirect_vector.h b/include/etl/indirect_vector.h index d98da3d5..3e6339af 100644 --- a/include/etl/indirect_vector.h +++ b/include/etl/indirect_vector.h @@ -1422,12 +1422,23 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template indirect_vector(T, Ts...) ->indirect_vector && ...), T>, 1U + sizeof...(Ts)>; #endif + //************************************************************************* + /// Make + //************************************************************************* +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + constexpr auto make_indirect_vector(T... t) -> etl::indirect_vector, sizeof...(T)> + { + return { { etl::forward(t)... } }; + } +#endif + //*************************************************************************** /// A indirect_vector implementation that uses a fixed size buffer. /// The buffer is supplied on construction. diff --git a/include/etl/list.h b/include/etl/list.h index 656a346f..60357cf6 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -2166,7 +2166,7 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template list(T...) -> list, sizeof...(T)>; @@ -2175,7 +2175,7 @@ namespace etl //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST template constexpr auto make_list(T... t) -> etl::list, sizeof...(T)> { diff --git a/include/etl/vector.h b/include/etl/vector.h index 4d768633..499092d9 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -1339,7 +1339,7 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template vector(T...) -> vector, sizeof...(T)>; #endif @@ -1347,7 +1347,7 @@ namespace etl //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST template constexpr auto make_vector(T... t) -> etl::vector, sizeof...(T)> { @@ -1641,12 +1641,12 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template vector(T*...) -> vector, sizeof...(T)>; #endif -#if ETL_CPP11_SUPPORTED +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST template constexpr auto make_vector(T*... t) -> etl::vector, sizeof...(T)> {