From d03e6f5587bdc5a192013e81307739dea7629eae Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 9 Nov 2021 19:46:25 +0000 Subject: [PATCH] Latest implementations --- include/etl/array.h | 6 ++-- include/etl/deque.h | 6 ++-- include/etl/flat_map.h | 21 +++++++------ include/etl/flat_multimap.h | 21 +++++++------ include/etl/flat_multiset.h | 43 +++++++++++++-------------- include/etl/flat_set.h | 15 +++++----- include/etl/forward_list.h | 6 ++-- include/etl/list.h | 3 +- include/etl/map.h | 23 +++++++------- include/etl/multimap.h | 29 +++++++----------- include/etl/multiset.h | 15 +++++----- include/etl/platform.h | 10 ++++--- include/etl/reference_flat_map.h | 21 +++++++------ include/etl/reference_flat_multimap.h | 21 +++++++------ include/etl/reference_flat_multiset.h | 16 +++++----- include/etl/reference_flat_set.h | 16 +++++----- include/etl/set.h | 15 +++++----- include/etl/type_lookup.h | 3 ++ include/etl/type_traits.h | 3 +- include/etl/unordered_map.h | 21 +++++++------ include/etl/unordered_multimap.h | 21 +++++++------ include/etl/unordered_multiset.h | 15 +++++----- include/etl/unordered_set.h | 15 +++++----- test/test_array.cpp | 4 +-- test/test_deque.cpp | 5 +--- test/test_flat_map.cpp | 2 +- test/test_flat_multimap.cpp | 2 +- test/test_flat_multiset.cpp | 4 +-- test/test_flat_set.cpp | 4 +-- test/test_forward_list.cpp | 4 +-- test/test_list.cpp | 4 +-- test/test_map.cpp | 4 +-- test/test_multimap.cpp | 4 +-- test/test_multiset.cpp | 6 ++-- test/test_set.cpp | 4 +-- test/test_vector.cpp | 4 +-- test/test_vector_pointer.cpp | 7 ++--- 37 files changed, 195 insertions(+), 228 deletions(-) diff --git a/include/etl/array.h b/include/etl/array.h index be23e651..23ce5d7b 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -565,10 +565,10 @@ namespace etl /// Make //************************************************************************* #if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_array(T&&... t) -> etl::array, sizeof...(T)> + template + constexpr auto make_array(TValues&&... values) -> etl::array { - return { { etl::forward(t)... } }; + return { { etl::forward(values)... } }; } #endif diff --git a/include/etl/deque.h b/include/etl/deque.h index 8cd1ee26..a7564afa 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -2462,10 +2462,10 @@ namespace etl /// Make //************************************************************************* #if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_deque(T&&... t) -> etl::deque::type, sizeof...(T)> + template + constexpr auto make_deque(TValues&&... values) -> etl::deque { - return { { etl::forward(t)... } }; + return { { etl::forward(values)... } }; } #endif diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index 129c0eb4..ee15d842 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -35,6 +35,7 @@ SOFTWARE. #include "reference_flat_map.h" #include "pool.h" #include "placement_new.h" +#include "type_lookup.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include @@ -1004,23 +1005,21 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED - template - flat_map(T...) -> flat_map, - typename etl::common_type_t, - sizeof...(T)>; +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + flat_map(TPairs...) -> flat_map::first_type, + typename etl::nth_type_t<0, TPairs...>::second_type, + sizeof...(TPairs)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_flat_map(T... t) -> etl::flat_map, - typename etl::common_type_t, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... TPairs> + constexpr auto make_flat_map(TPairs&&... pairs) -> etl::flat_map { - return { { etl::forward(t)... } }; + return { {etl::forward(pairs)...} }; } #endif } diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index 233d21b2..e1f8fcf7 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -36,6 +36,7 @@ SOFTWARE. #include "pool.h" #include "utility.h" #include "placement_new.h" +#include "type_lookup.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include @@ -907,23 +908,21 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED - template - flat_multimap(T...) -> flat_multimap, - typename etl::common_type_t, - sizeof...(T)>; +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + flat_multimap(TPairs...) -> flat_multimap::first_type, + typename etl::nth_type_t<0, TPairs...>::second_type, + sizeof...(TPairs)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_flat_multimap(T... t) -> etl::flat_multimap, - typename etl::common_type_t, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... TPairs> + constexpr auto make_flat_multimap(TPairs&&... pairs) -> etl::flat_multimap { - return { { etl::forward(t)... } }; + return { {etl::forward(pairs)...} }; } #endif } diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 67955fb0..cbfcb8d6 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -35,6 +35,7 @@ SOFTWARE. #include "reference_flat_multiset.h" #include "pool.h" #include "placement_new.h" +#include "type_lookup.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include @@ -69,12 +70,12 @@ namespace etl typedef T key_type; typedef T value_type; typedef TKeyCompare key_compare; - typedef value_type& reference; + typedef value_type& reference; typedef const value_type& const_reference; #if ETL_CPP11_SUPPORTED - typedef value_type&& rvalue_reference; + typedef value_type&& rvalue_reference; #endif - typedef value_type* pointer; + typedef value_type* pointer; typedef const value_type* const_pointer; typedef size_t size_type; @@ -234,7 +235,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); ETL_INCREMENT_DEBUG_COUNT - result = refset_t::insert_at(i_element, *pvalue); + result = refset_t::insert_at(i_element, *pvalue); return result; } @@ -327,7 +328,7 @@ namespace etl iterator i_element = upper_bound(*pvalue); ETL_INCREMENT_DEBUG_COUNT - return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); } #else //************************************************************************* @@ -345,7 +346,7 @@ namespace etl iterator i_element = upper_bound(*pvalue); ETL_INCREMENT_DEBUG_COUNT - return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); } //************************************************************************* @@ -363,7 +364,7 @@ namespace etl iterator i_element = upper_bound(*pvalue); ETL_INCREMENT_DEBUG_COUNT - return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); } //************************************************************************* @@ -381,7 +382,7 @@ namespace etl iterator i_element = upper_bound(*pvalue); ETL_INCREMENT_DEBUG_COUNT - return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); } //************************************************************************* @@ -399,7 +400,7 @@ namespace etl iterator i_element = upper_bound(*pvalue); ETL_INCREMENT_DEBUG_COUNT - return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); + return ETL_OR_STD::pair(refset_t::insert_at(i_element, *pvalue)); } #endif @@ -480,7 +481,7 @@ namespace etl } ETL_RESET_DEBUG_COUNT - refset_t::clear(); + refset_t::clear(); } //********************************************************************* @@ -659,7 +660,7 @@ namespace etl //********************************************************************* iflat_multiset(lookup_t& lookup_, storage_t& storage_) : refset_t(lookup_), - storage(storage_) + storage(storage_) { } @@ -698,9 +699,9 @@ namespace etl /// Internal debugging. ETL_DECLARE_DEBUG_COUNT - //************************************************************************* - /// Destructor. - //************************************************************************* + //************************************************************************* + /// Destructor. + //************************************************************************* #if defined(ETL_POLYMORPHIC_FLAT_MULTISET) || defined(ETL_POLYMORPHIC_CONTAINERS) public: virtual ~iflat_multiset() @@ -859,21 +860,19 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template - flat_multiset(T...) -> flat_multiset, - sizeof...(T)>; + flat_multiset(T...) -> flat_multiset, sizeof...(T)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_flat_multiset(T... t) -> etl::flat_multiset, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... T> + constexpr auto make_flat_multiset(T&&... keys) -> etl::flat_multiset { - return { { etl::forward(t)... } }; + return { {etl::forward(keys)...} }; } #endif } diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index 592fb26f..83a15b56 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -35,6 +35,7 @@ SOFTWARE. #include "reference_flat_set.h" #include "pool.h" #include "placement_new.h" +#include "type_lookup.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include @@ -944,21 +945,19 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template - flat_set(T...) -> flat_set, - sizeof...(T)>; + flat_set(T...) -> flat_set, sizeof...(T)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_flat_set(T... t) -> etl::flat_set, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... T> + constexpr auto make_flat_set(T&&... keys) -> etl::flat_set { - return { { etl::forward(t)... } }; + return { {etl::forward(keys)...} }; } #endif } diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index f7092a9e..5d0ed1cb 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -1720,8 +1720,7 @@ namespace etl //************************************************************************* #if ETL_CPP17_SUPPORTED template - forward_list(T...) ->forward_list, - sizeof...(T)>; + forward_list(T...) ->forward_list, sizeof...(T)>; #endif //************************************************************************* @@ -1729,8 +1728,7 @@ namespace etl //************************************************************************* #if ETL_USING_INITIALIZER_LIST template - constexpr auto make_forward_list(T... t) -> etl::forward_list, - sizeof...(T)> + constexpr auto make_forward_list(T... t) -> etl::forward_list, sizeof...(T)> { return { { etl::forward(t)... } }; } diff --git a/include/etl/list.h b/include/etl/list.h index 4a0623dc..134c5381 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -2162,8 +2162,7 @@ namespace etl //************************************************************************* #if ETL_USING_INITIALIZER_LIST template - constexpr auto make_list(T... t) -> etl::list, - sizeof...(T)> + constexpr auto make_list(T... t) -> etl::list, sizeof...(T)> { return { { etl::forward(t)... } }; } diff --git a/include/etl/map.h b/include/etl/map.h index 8d0830c3..94f27d9c 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -7,7 +7,7 @@ Embedded Template Library. https://github.com/ETLCPP/etl https://www.etlcpp.com -Copyright(c) 2014 jwellbelove, rlindeman +Copyright(c) 2021 jwellbelove Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal @@ -43,6 +43,7 @@ SOFTWARE. #include "debug_count.h" #include "nullptr.h" #include "type_traits.h" +#include "type_lookup.h" #include "parameter_type.h" #include "iterator.h" #include "utility.h" @@ -2279,23 +2280,21 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED - template - map(T...) -> map, - typename etl::common_type_t, - sizeof...(T)>; +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + map(TPairs...) -> map::first_type, + typename etl::nth_type_t<0, TPairs...>::second_type, + sizeof...(TPairs)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_map(T... t) -> etl::map, - typename etl::common_type_t, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... TPairs> + constexpr auto make_map(TPairs&&... pairs) -> etl::map { - return { { etl::forward(t)... } }; + return { {etl::forward(pairs)...} }; } #endif diff --git a/include/etl/multimap.h b/include/etl/multimap.h index 90a4a944..17e06b19 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -43,6 +43,7 @@ SOFTWARE. #include "debug_count.h" #include "nullptr.h" #include "type_traits.h" +#include "type_lookup.h" #include "parameter_type.h" #include "iterator.h" #include "utility.h" @@ -2138,31 +2139,21 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL - template - multimap(T, Ts...) - ->multimap && ...), typename T::first_type>, - typename T::second_type, - 1U + sizeof...(Ts)>; -#endif - -#if ETL_CPP17_SUPPORTED - template - multimap(T...) -> multimap, - typename etl::common_type_t, - sizeof...(T)>; +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + multimap(TPairs...) -> multimap::first_type, + typename etl::nth_type_t<0, TPairs...>::second_type, + sizeof...(TPairs)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_multimap(T... t) -> etl::multimap, - typename etl::common_type_t, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... TPairs> + constexpr auto make_multimap(TPairs&&... pairs) -> etl::multimap { - return { { etl::forward(t)... } }; + return { {etl::forward(pairs)...} }; } #endif diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 0ebf55f6..7841fecb 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -44,6 +44,7 @@ SOFTWARE. #include "debug_count.h" #include "nullptr.h" #include "type_traits.h" +#include "type_lookup.h" #include "utility.h" #include "placement_new.h" @@ -2121,21 +2122,19 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template - multiset(T...) -> multiset, - sizeof...(T)>; + multiset(T...) -> multiset, sizeof...(T)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_multiset(T... t) -> etl::multiset, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... T> + constexpr auto make_multiset(T&&... keys) -> etl::multiset { - return { { etl::forward(t)... } }; + return { {etl::forward(keys)...} }; } #endif diff --git a/include/etl/platform.h b/include/etl/platform.h index f0c36867..1456b0f3 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -211,10 +211,12 @@ SOFTWARE. #define ETL_CONSTINIT #endif -#if ETL_CPP11_SUPPORTED && ETL_USING_STL && ETL_NOT_USING_STLPORT - #define ETL_USING_INITIALIZER_LIST 1 -#else - #define ETL_USING_INITIALIZER_LIST 0 +#if !defined(ETL_USING_INITIALIZER_LIST) + #if ETL_CPP11_SUPPORTED && ETL_USING_STL && ETL_NOT_USING_STLPORT + #define ETL_USING_INITIALIZER_LIST 1 + #else + #define ETL_USING_INITIALIZER_LIST 0 + #endif #endif // Check for availability of certain builtins diff --git a/include/etl/reference_flat_map.h b/include/etl/reference_flat_map.h index ed74c37f..5e5d1efa 100644 --- a/include/etl/reference_flat_map.h +++ b/include/etl/reference_flat_map.h @@ -38,6 +38,7 @@ SOFTWARE. #include "error_handler.h" #include "debug_count.h" #include "type_traits.h" +#include "type_lookup.h" #include "parameter_type.h" #include "exception.h" #include "static_assert.h" @@ -965,23 +966,21 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED - template - reference_flat_map(T...) -> reference_flat_map, - typename etl::common_type_t, - sizeof...(T)>; +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + reference_flat_map(TPairs...) -> reference_flat_map::first_type, + typename etl::nth_type_t<0, TPairs...>::second_type, + sizeof...(TPairs)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_reference_flat_map(T... t) -> etl::reference_flat_map, - typename etl::common_type_t, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... TPairs> + constexpr auto make_reference_flat_map(TPairs&&... pairs) -> etl::reference_flat_map { - return { { etl::forward(t)... } }; + return { {etl::forward(pairs)...} }; } #endif } diff --git a/include/etl/reference_flat_multimap.h b/include/etl/reference_flat_multimap.h index 4ba5235a..0e4c2643 100644 --- a/include/etl/reference_flat_multimap.h +++ b/include/etl/reference_flat_multimap.h @@ -39,6 +39,7 @@ SOFTWARE. #include "debug_count.h" #include "vector.h" #include "iterator.h" +#include "type_lookup.h" namespace etl { @@ -862,23 +863,21 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED - template - reference_flat_multimap(T...)->reference_flat_multimap, - typename etl::common_type_t, - sizeof...(T)>; +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + reference_flat_multimap(TPairs...) -> reference_flat_multimap::first_type, + typename etl::nth_type_t<0, TPairs...>::second_type, + sizeof...(TPairs)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_reference_flat_multimap(T... t) -> etl::reference_flat_multimap, - typename etl::common_type_t, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... TPairs> + constexpr auto make_reference_flat_multimap(TPairs&&... pairs) -> etl::reference_flat_multimap { - return { { etl::forward(t)... } }; + return { {etl::forward(pairs)...} }; } #endif } diff --git a/include/etl/reference_flat_multiset.h b/include/etl/reference_flat_multiset.h index fa491c6b..3aa3dff9 100644 --- a/include/etl/reference_flat_multiset.h +++ b/include/etl/reference_flat_multiset.h @@ -39,8 +39,8 @@ SOFTWARE. #include "iterator.h" #include "functional.h" #include "utility.h" - #include "type_traits.h" +#include "type_lookup.h" #include "vector.h" #include "pool.h" #include "error_handler.h" @@ -843,21 +843,19 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template - reference_flat_multiset(T...) -> reference_flat_multiset, - sizeof...(T)>; + reference_flat_multiset(T...)->reference_flat_multiset, sizeof...(T)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_reference_flat_multiset(T... t) -> etl::reference_flat_multiset, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... T> + constexpr auto make_reference_flat_multiset(T&&... keys) -> etl::reference_flat_multiset { - return { { etl::forward(t)... } }; + return { {etl::forward(keys)...} }; } #endif diff --git a/include/etl/reference_flat_set.h b/include/etl/reference_flat_set.h index a08f8c19..1e75f15c 100644 --- a/include/etl/reference_flat_set.h +++ b/include/etl/reference_flat_set.h @@ -39,8 +39,8 @@ SOFTWARE. #include "iterator.h" #include "functional.h" #include "utility.h" - #include "type_traits.h" +#include "type_lookup.h" #include "pool.h" #include "error_handler.h" #include "exception.h" @@ -827,21 +827,19 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template - reference_flat_set(T...) -> reference_flat_set, - sizeof...(T)>; + reference_flat_set(T...) -> reference_flat_set, sizeof...(T)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_reference_flat_set(T... t) -> etl::reference_flat_set, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... T> + constexpr auto make_reference_flat_set(T&&... keys) -> etl::reference_flat_set { - return { { etl::forward(t)... } }; + return { {etl::forward(keys)...} }; } #endif diff --git a/include/etl/set.h b/include/etl/set.h index 8f75b223..ded5d553 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -47,6 +47,7 @@ SOFTWARE. #include "iterator.h" #include "functional.h" #include "placement_new.h" +#include "type_lookup.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include @@ -2203,21 +2204,19 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template - set(T...) -> set, - sizeof...(T)>; + set(T...) -> set, sizeof...(T)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_set(T... t) -> etl::set, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template , typename... T> + constexpr auto make_set(T&&... keys) -> etl::set { - return { { etl::forward(t)... } }; + return { {etl::forward(keys)...} }; } #endif diff --git a/include/etl/type_lookup.h b/include/etl/type_lookup.h index dd92d57d..7f20826f 100644 --- a/include/etl/type_lookup.h +++ b/include/etl/type_lookup.h @@ -237,6 +237,9 @@ namespace etl using type = typename private_nth_type::nth_type_helper::type; }; + template + using nth_type_t = typename nth_type::type; + #else //*************************************************************************** diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index e0d7913d..9683b801 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -2018,10 +2018,11 @@ namespace etl //********************************************* // common_type - // Based on the implementation detailed on + // 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 diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index 650d8020..428c9ef9 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -43,6 +43,7 @@ SOFTWARE. #include "intrusive_forward_list.h" #include "hash.h" #include "type_traits.h" +#include "type_lookup.h" #include "parameter_type.h" #include "nullptr.h" #include "vector.h" @@ -1631,23 +1632,21 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED - template - unordered_map(T...) -> unordered_map, - typename etl::common_type_t, - sizeof...(T)>; +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + unordered_map(TPairs...) -> unordered_map::first_type, + typename etl::nth_type_t<0, TPairs...>::second_type, + sizeof...(TPairs)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_unordered_map(T... t) -> etl::unordered_map, - typename etl::common_type_t, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + constexpr auto make_unordered_map(TPairs&&... pairs) -> etl::unordered_map { - return { { etl::forward(t)... } }; + return { {etl::forward(pairs)...} }; } #endif } diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index 81b46ba6..33e67851 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -43,6 +43,7 @@ SOFTWARE. #include "intrusive_forward_list.h" #include "hash.h" #include "type_traits.h" +#include "type_lookup.h" #include "parameter_type.h" #include "nullptr.h" #include "pool.h" @@ -1542,23 +1543,21 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED - template - unordered_multimap(T...) ->unordered_multimap, - typename etl::common_type_t, - sizeof...(T)>; +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + unordered_multimap(TPairs...) -> unordered_multimap::first_type, + typename etl::nth_type_t<0, TPairs...>::second_type, + sizeof...(TPairs)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_unordered_multimap(T... t) -> etl::unordered_multimap, - typename etl::common_type_t, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + constexpr auto make_unordered_multimap(TPairs&&... pairs) -> etl::unordered_multimap { - return { { etl::forward(t)... } }; + return { {etl::forward(pairs)...} }; } #endif } diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index ee8a4a53..f5642fc8 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -43,6 +43,7 @@ SOFTWARE. #include "intrusive_forward_list.h" #include "hash.h" #include "type_traits.h" +#include "type_lookup.h" #include "parameter_type.h" #include "nullptr.h" #include "error_handler.h" @@ -1528,21 +1529,19 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template - unordered_multiset(T...) -> unordered_multiset, - sizeof...(T)>; + unordered_multiset(T...) -> unordered_multiset, sizeof...(T)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_unordered_multiset(T... t) -> etl::unordered_multiset, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + constexpr auto make_unordered_multiset(T&&... keys) -> etl::unordered_multiset { - return { { etl::forward(t)... } }; + return { {etl::forward(keys)...} }; } #endif } diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index fa47d5cf..739745a4 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -43,6 +43,7 @@ SOFTWARE. #include "intrusive_forward_list.h" #include "hash.h" #include "type_traits.h" +#include "type_lookup.h" #include "parameter_type.h" #include "nullptr.h" #include "error_handler.h" @@ -1526,21 +1527,19 @@ namespace etl //************************************************************************* /// Template deduction guides. //************************************************************************* -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST template - unordered_set(T...) -> unordered_set, - sizeof...(T)>; + unordered_set(T...) -> unordered_set, sizeof...(T)>; #endif //************************************************************************* /// Make //************************************************************************* -#if ETL_USING_INITIALIZER_LIST - template - constexpr auto make_unordered_set(T... t) -> etl::unordered_set, - sizeof...(T)> +#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST + template + constexpr auto make_unordered_set(T&&... keys) -> etl::unordered_set { - return { { etl::forward(t)... } }; + return { {etl::forward(keys)...} }; } #endif } diff --git a/test/test_array.cpp b/test/test_array.cpp index d38b38dc..e8850d95 100644 --- a/test/test_array.cpp +++ b/test/test_array.cpp @@ -672,10 +672,10 @@ namespace #if ETL_USING_INITIALIZER_LIST TEST(test_make_array) { - auto data = etl::make_array(char(0), short(1), int(2), long(3), 4, 5, 6, 7, 8, 9); + auto data = etl::make_array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); using Type = std::remove_reference_t; - CHECK((std::is_same_v)); + CHECK((std::is_same_v)); CHECK_EQUAL(0, data[0]); CHECK_EQUAL(1, data[1]); diff --git a/test/test_deque.cpp b/test/test_deque.cpp index af3a3cb0..0f2cc3d2 100644 --- a/test/test_deque.cpp +++ b/test/test_deque.cpp @@ -2035,10 +2035,7 @@ namespace #if ETL_USING_INITIALIZER_LIST TEST(test_make_deque) { - auto data = etl::make_deque(char(0), short(1), int(2), long(3), 4, 5, 6, 7, 8, 9); - - using Type = std::remove_reference_t; - CHECK((std::is_same_v)); + auto data = etl::make_deque(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); CHECK_EQUAL(0, data[0]); CHECK_EQUAL(1, data[1]); diff --git a/test/test_flat_map.cpp b/test/test_flat_map.cpp index f26703d3..ef32a3ad 100644 --- a/test/test_flat_map.cpp +++ b/test/test_flat_map.cpp @@ -1289,7 +1289,7 @@ namespace { using Pair = ETL_OR_STD::pair; - auto data = etl::make_flat_map(Pair(0, NDC("A")), Pair(1, NDC("B")), Pair(2, NDC("C")), Pair(3, NDC("D")), Pair(4, NDC("E")), Pair(5, NDC("F"))); + auto data = etl::make_flat_map(Pair(0, NDC("A")), Pair(1, NDC("B")), Pair(2, NDC("C")), Pair(3, NDC("D")), Pair(4, NDC("E")), Pair(5, NDC("F"))); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_flat_multimap.cpp b/test/test_flat_multimap.cpp index dc4098e2..385297b0 100644 --- a/test/test_flat_multimap.cpp +++ b/test/test_flat_multimap.cpp @@ -1099,7 +1099,7 @@ namespace { using Pair = ETL_OR_STD::pair; - auto data = etl::make_flat_multimap(Pair(0, NDC("A")), Pair(1, NDC("B")), Pair(1, NDC("B2")), Pair(2, NDC("C")), Pair(3, NDC("D")), Pair(4, NDC("E")), Pair(5, NDC("F"))); + auto data = etl::make_flat_multimap(Pair(0, NDC("A")), Pair(1, NDC("B")), Pair(1, NDC("B2")), Pair(2, NDC("C")), Pair(3, NDC("D")), Pair(4, NDC("E")), Pair(5, NDC("F"))); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_flat_multiset.cpp b/test/test_flat_multiset.cpp index 8a2ab2c7..3a4a9712 100644 --- a/test/test_flat_multiset.cpp +++ b/test/test_flat_multiset.cpp @@ -1055,9 +1055,7 @@ namespace #if ETL_USING_INITIALIZER_LIST TEST(test_make_flat_multiset) { - using Pair = ETL_OR_STD::pair; - - auto data = etl::make_flat_multiset(NDC("A"), NDC("B"), NDC("B2"), NDC("C"), NDC("D"), NDC("E"), NDC("F")); + auto data = etl::make_flat_multiset(NDC("A"), NDC("B"), NDC("B2"), NDC("C"), NDC("D"), NDC("E"), NDC("F")); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_flat_set.cpp b/test/test_flat_set.cpp index c59723a6..cd436cee 100644 --- a/test/test_flat_set.cpp +++ b/test/test_flat_set.cpp @@ -984,9 +984,7 @@ namespace #if ETL_USING_INITIALIZER_LIST TEST(test_make_flat_set) { - using Pair = ETL_OR_STD::pair; - - auto data = etl::make_flat_set(NDC("A"), NDC("B"), NDC("C"), NDC("D"), NDC("E"), NDC("F")); + auto data = etl::make_flat_set(NDC("A"), NDC("B"), NDC("C"), NDC("D"), NDC("E"), NDC("F")); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_forward_list.cpp b/test/test_forward_list.cpp index e804d836..17340ea0 100644 --- a/test/test_forward_list.cpp +++ b/test/test_forward_list.cpp @@ -1373,9 +1373,9 @@ namespace //************************************************************************* #if ETL_USING_INITIALIZER_LIST - TEST(test_make_flat_map) + TEST(test_make_forward_list) { - auto data = etl::make_forward_list(ItemNDC("A"), ItemNDC("B"), ItemNDC("C"), ItemNDC("D"), ItemNDC("E"), ItemNDC("F")); + auto data = etl::make_forward_list(ItemNDC("A"), ItemNDC("B"), ItemNDC("C"), ItemNDC("D"), ItemNDC("E"), ItemNDC("F")); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_list.cpp b/test/test_list.cpp index 85d2be0e..d9e618eb 100644 --- a/test/test_list.cpp +++ b/test/test_list.cpp @@ -2051,9 +2051,9 @@ namespace //************************************************************************* #if ETL_USING_INITIALIZER_LIST - TEST(test_make_flat_map) + TEST(test_make_list) { - auto data = etl::make_list(ItemNDC("A"), ItemNDC("B"), ItemNDC("C"), ItemNDC("D"), ItemNDC("E"), ItemNDC("F")); + auto data = etl::make_list(ItemNDC("A"), ItemNDC("B"), ItemNDC("C"), ItemNDC("D"), ItemNDC("E"), ItemNDC("F")); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_map.cpp b/test/test_map.cpp index 036c0a2c..8530dfab 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -1286,7 +1286,7 @@ namespace { using Pair = std::pair; - etl::map data{ Pair("0", 0), Pair("1", 1), Pair("2", 2), Pair("3", 3), Pair("4", 4), Pair("5", 5) }; + etl::map data { Pair{"0", 0}, Pair{"1", 1}, Pair{"2", 2}, Pair{"3", 3}, Pair{"4", 4}, Pair{"5", 5} }; auto v = *data.begin(); using Type = decltype(v); @@ -1307,7 +1307,7 @@ namespace { using Pair = ETL_OR_STD::pair; - auto data = etl::make_map(Pair("0", 0), Pair("1", 1), Pair("2", 2), Pair("3", 3), Pair("4", 4), Pair("5", 5)); + auto data = etl::make_map>(Pair{ "0", 0 }, Pair{ "1", 1 }, Pair{ "2", 2 }, Pair{ "3", 3 }, Pair{ "4", 4 }, Pair{ "5", 5 }); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_multimap.cpp b/test/test_multimap.cpp index 797aa7c5..a09720f4 100644 --- a/test/test_multimap.cpp +++ b/test/test_multimap.cpp @@ -1275,11 +1275,11 @@ namespace //************************************************************************* #if ETL_USING_INITIALIZER_LIST - TEST(test_make_map) + TEST(test_make_multimap) { using Pair = ETL_OR_STD::pair; - auto data = etl::make_multimap(Pair("0", 0), Pair("1", 1), Pair("2", 2), Pair("3", 3), Pair("4", 4), Pair("5", 5)); + auto data = etl::make_multimap>(Pair("0", 0), Pair("1", 1), Pair("2", 2), Pair("3", 3), Pair("4", 4), Pair("5", 5)); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_multiset.cpp b/test/test_multiset.cpp index 7da491a5..d0d7efb6 100644 --- a/test/test_multiset.cpp +++ b/test/test_multiset.cpp @@ -1253,7 +1253,7 @@ namespace //************************************************************************* #if ETL_USING_INITIALIZER_LIST - TEST(test_set_template_deduction) + TEST(test_multiset_template_deduction) { etl::multiset data{ std::string("A"), std::string("B"), std::string("C"), std::string("D"), std::string("E"), std::string("F") }; @@ -1279,9 +1279,9 @@ namespace //************************************************************************* #if ETL_USING_INITIALIZER_LIST - TEST(test_make_flat_set) + TEST(test_make_multiset) { - auto data = etl::make_multiset(std::string("A"), std::string("B"), std::string("C"), std::string("D"), std::string("E"), std::string("F")); + auto data = etl::make_multiset< std::string>(std::string("A"), std::string("B"), std::string("C"), std::string("D"), std::string("E"), std::string("F")); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_set.cpp b/test/test_set.cpp index 17adc7cb..bd603d13 100644 --- a/test/test_set.cpp +++ b/test/test_set.cpp @@ -1226,9 +1226,9 @@ namespace //************************************************************************* #if ETL_USING_INITIALIZER_LIST - TEST(test_make_flat_set) + TEST(test_make_set) { - auto data = etl::make_set(std::string("A"), std::string("B"), std::string("C"), std::string("D"), std::string("E"), std::string("F")); + auto data = etl::make_set< std::string>(std::string("A"), std::string("B"), std::string("C"), std::string("D"), std::string("E"), std::string("F")); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_vector.cpp b/test/test_vector.cpp index 06258214..4ad6aeab 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -1308,10 +1308,10 @@ namespace #if ETL_USING_INITIALIZER_LIST TEST(test_make_vector) { - auto data = etl::make_vector(char(0), short(1), int(2), long(3), 4, 5, 6, 7, 8, 9); + auto data = etl::make_vector(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); using Type = std::remove_reference_t; - CHECK((std::is_same_v)); + CHECK((std::is_same_v)); CHECK_EQUAL(0, data[0]); CHECK_EQUAL(1, data[1]); diff --git a/test/test_vector_pointer.cpp b/test/test_vector_pointer.cpp index 2546e09d..38db7dec 100644 --- a/test/test_vector_pointer.cpp +++ b/test/test_vector_pointer.cpp @@ -1921,12 +1921,9 @@ namespace #if ETL_USING_INITIALIZER_LIST TEST(test_make_vector) { - const long values[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int values[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - auto data = etl::make_vector( &values[0], &values[1], &values[2], &values[3], &values[4], &values[5], &values[6], &values[7], &values[8], &values[9] ); - - using Type = std::remove_reference_t; - CHECK((std::is_same_v)); + auto data = etl::make_vector( &values[0], &values[1], &values[2], &values[3], &values[4], &values[5], &values[6], &values[7], &values[8], &values[9] ); CHECK_EQUAL(0, *data[0]); CHECK_EQUAL(1, *data[1]);