Latest implementations

This commit is contained in:
John Wellbelove 2021-11-09 19:46:25 +00:00
parent 84974acbfa
commit d03e6f5587
37 changed files with 195 additions and 228 deletions

View File

@ -565,10 +565,10 @@ namespace etl
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_array(T&&... t) -> etl::array<typename etl::common_type_t<T...>, sizeof...(T)>
template <typename T, typename... TValues>
constexpr auto make_array(TValues&&... values) -> etl::array<T, sizeof...(TValues)>
{
return { { etl::forward<T>(t)... } };
return { { etl::forward<T>(values)... } };
}
#endif

View File

@ -2462,10 +2462,10 @@ namespace etl
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_deque(T&&... t) -> etl::deque<typename etl::common_type<T...>::type, sizeof...(T)>
template <typename T, typename... TValues>
constexpr auto make_deque(TValues&&... values) -> etl::deque<T, sizeof...(TValues)>
{
return { { etl::forward<T>(t)... } };
return { { etl::forward<T>(values)... } };
}
#endif

View File

@ -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 <initializer_list>
@ -1004,23 +1005,21 @@ namespace etl
//*************************************************************************
/// Template deduction guides.
//*************************************************************************
#if ETL_CPP17_SUPPORTED
template <typename... T>
flat_map(T...) -> flat_map<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>;
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename... TPairs>
flat_map(TPairs...) -> flat_map<typename etl::nth_type_t<0, TPairs...>::first_type,
typename etl::nth_type_t<0, TPairs...>::second_type,
sizeof...(TPairs)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_flat_map(T... t) -> etl::flat_map<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TMapped, typename TKeyCompare = etl::less<TKey>, typename... TPairs>
constexpr auto make_flat_map(TPairs&&... pairs) -> etl::flat_map<TKey, TMapped, sizeof...(TPairs), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<TPairs>(pairs)...} };
}
#endif
}

View File

@ -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 <initializer_list>
@ -907,23 +908,21 @@ namespace etl
//*************************************************************************
/// Template deduction guides.
//*************************************************************************
#if ETL_CPP17_SUPPORTED
template <typename... T>
flat_multimap(T...) -> flat_multimap<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>;
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename... TPairs>
flat_multimap(TPairs...) -> flat_multimap<typename etl::nth_type_t<0, TPairs...>::first_type,
typename etl::nth_type_t<0, TPairs...>::second_type,
sizeof...(TPairs)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_flat_multimap(T... t) -> etl::flat_multimap<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TMapped, typename TKeyCompare = etl::less<TKey>, typename... TPairs>
constexpr auto make_flat_multimap(TPairs&&... pairs) -> etl::flat_multimap<TKey, TMapped, sizeof...(TPairs), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<TPairs>(pairs)...} };
}
#endif
}

View File

@ -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 <initializer_list>
@ -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<value_type>();
::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<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
return ETL_OR_STD::pair<iterator, bool>(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<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
return ETL_OR_STD::pair<iterator, bool>(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<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
return ETL_OR_STD::pair<iterator, bool>(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<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
return ETL_OR_STD::pair<iterator, bool>(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<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
return ETL_OR_STD::pair<iterator, bool>(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 <typename... T>
flat_multiset(T...) -> flat_multiset<typename etl::common_type_t<T...>,
sizeof...(T)>;
flat_multiset(T...) -> flat_multiset<etl::nth_type_t<0, T...>, sizeof...(T)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_flat_multiset(T... t) -> etl::flat_multiset<typename etl::common_type_t<T...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TKeyCompare = etl::less<TKey>, typename... T>
constexpr auto make_flat_multiset(T&&... keys) -> etl::flat_multiset<TKey, sizeof...(T), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<T>(keys)...} };
}
#endif
}

View File

@ -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 <initializer_list>
@ -944,21 +945,19 @@ namespace etl
//*************************************************************************
/// Template deduction guides.
//*************************************************************************
#if ETL_CPP17_SUPPORTED
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename... T>
flat_set(T...) -> flat_set<typename etl::common_type_t<T...>,
sizeof...(T)>;
flat_set(T...) -> flat_set<etl::nth_type_t<0, T...>, sizeof...(T)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_flat_set(T... t) -> etl::flat_set<typename etl::common_type_t<T...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TKeyCompare = etl::less<TKey>, typename... T>
constexpr auto make_flat_set(T&&... keys) -> etl::flat_set<TKey, sizeof...(T), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<T>(keys)...} };
}
#endif
}

View File

@ -1720,8 +1720,7 @@ namespace etl
//*************************************************************************
#if ETL_CPP17_SUPPORTED
template <typename... T>
forward_list(T...) ->forward_list<typename etl::common_type_t<T...>,
sizeof...(T)>;
forward_list(T...) ->forward_list<typename etl::common_type_t<T...>, sizeof...(T)>;
#endif
//*************************************************************************
@ -1729,8 +1728,7 @@ namespace etl
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_forward_list(T... t) -> etl::forward_list<typename etl::common_type_t<T...>,
sizeof...(T)>
constexpr auto make_forward_list(T... t) -> etl::forward_list<typename etl::common_type_t<T...>, sizeof...(T)>
{
return { { etl::forward<T>(t)... } };
}

View File

@ -2162,8 +2162,7 @@ namespace etl
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_list(T... t) -> etl::list<typename etl::common_type_t<T...>,
sizeof...(T)>
constexpr auto make_list(T... t) -> etl::list<typename etl::common_type_t<T...>, sizeof...(T)>
{
return { { etl::forward<T>(t)... } };
}

View File

@ -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 <typename... T>
map(T...) -> map<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>;
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename... TPairs>
map(TPairs...) -> map<typename etl::nth_type_t<0, TPairs...>::first_type,
typename etl::nth_type_t<0, TPairs...>::second_type,
sizeof...(TPairs)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_map(T... t) -> etl::map<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TMapped, typename TKeyCompare = etl::less<TKey>, typename... TPairs>
constexpr auto make_map(TPairs&&... pairs) -> etl::map<TKey, TMapped, sizeof...(TPairs), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<TPairs>(pairs)...} };
}
#endif

View File

@ -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 <typename T, typename... Ts>
multimap(T, Ts...)
->multimap<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), typename T::first_type>,
typename T::second_type,
1U + sizeof...(Ts)>;
#endif
#if ETL_CPP17_SUPPORTED
template <typename... T>
multimap(T...) -> multimap<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>;
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename... TPairs>
multimap(TPairs...) -> multimap<typename etl::nth_type_t<0, TPairs...>::first_type,
typename etl::nth_type_t<0, TPairs...>::second_type,
sizeof...(TPairs)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_multimap(T... t) -> etl::multimap<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TMapped, typename TKeyCompare = etl::less<TKey>, typename... TPairs>
constexpr auto make_multimap(TPairs&&... pairs) -> etl::multimap<TKey, TMapped, sizeof...(TPairs), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<TPairs>(pairs)...} };
}
#endif

View File

@ -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 <typename... T>
multiset(T...) -> multiset<typename etl::common_type_t<T...>,
sizeof...(T)>;
multiset(T...) -> multiset<etl::nth_type_t<0, T...>, sizeof...(T)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_multiset(T... t) -> etl::multiset<typename etl::common_type_t<T...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TKeyCompare = etl::less<TKey>, typename... T>
constexpr auto make_multiset(T&&... keys) -> etl::multiset<TKey, sizeof...(T), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<T>(keys)...} };
}
#endif

View File

@ -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

View File

@ -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 <typename... T>
reference_flat_map(T...) -> reference_flat_map<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>;
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename... TPairs>
reference_flat_map(TPairs...) -> reference_flat_map<typename etl::nth_type_t<0, TPairs...>::first_type,
typename etl::nth_type_t<0, TPairs...>::second_type,
sizeof...(TPairs)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_reference_flat_map(T... t) -> etl::reference_flat_map<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TMapped, typename TKeyCompare = etl::less<TKey>, typename... TPairs>
constexpr auto make_reference_flat_map(TPairs&&... pairs) -> etl::reference_flat_map<TKey, TMapped, sizeof...(TPairs), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<TPairs>(pairs)...} };
}
#endif
}

View File

@ -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 <typename... T>
reference_flat_multimap(T...)->reference_flat_multimap<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>;
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename... TPairs>
reference_flat_multimap(TPairs...) -> reference_flat_multimap<typename etl::nth_type_t<0, TPairs...>::first_type,
typename etl::nth_type_t<0, TPairs...>::second_type,
sizeof...(TPairs)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_reference_flat_multimap(T... t) -> etl::reference_flat_multimap<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TMapped, typename TKeyCompare = etl::less<TKey>, typename... TPairs>
constexpr auto make_reference_flat_multimap(TPairs&&... pairs) -> etl::reference_flat_multimap<TKey, TMapped, sizeof...(TPairs), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<TPairs>(pairs)...} };
}
#endif
}

View File

@ -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 <typename... T>
reference_flat_multiset(T...) -> reference_flat_multiset<typename etl::common_type_t<T...>,
sizeof...(T)>;
reference_flat_multiset(T...)->reference_flat_multiset<etl::nth_type_t<0, T...>, sizeof...(T)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_reference_flat_multiset(T... t) -> etl::reference_flat_multiset<typename etl::common_type_t<T...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TKeyCompare = etl::less<TKey>, typename... T>
constexpr auto make_reference_flat_multiset(T&&... keys) -> etl::reference_flat_multiset<TKey, sizeof...(T), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<T>(keys)...} };
}
#endif

View File

@ -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 <typename... T>
reference_flat_set(T...) -> reference_flat_set<typename etl::common_type_t<T...>,
sizeof...(T)>;
reference_flat_set(T...) -> reference_flat_set<etl::nth_type_t<0, T...>, sizeof...(T)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_reference_flat_set(T... t) -> etl::reference_flat_set<typename etl::common_type_t<T...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TKeyCompare = etl::less<TKey>, typename... T>
constexpr auto make_reference_flat_set(T&&... keys) -> etl::reference_flat_set<TKey, sizeof...(T), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<T>(keys)...} };
}
#endif

View File

@ -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 <initializer_list>
@ -2203,21 +2204,19 @@ namespace etl
//*************************************************************************
/// Template deduction guides.
//*************************************************************************
#if ETL_CPP17_SUPPORTED
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename... T>
set(T...) -> set<typename etl::common_type_t<T...>,
sizeof...(T)>;
set(T...) -> set<etl::nth_type_t<0, T...>, sizeof...(T)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_set(T... t) -> etl::set<typename etl::common_type_t<T...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TKeyCompare = etl::less<TKey>, typename... T>
constexpr auto make_set(T&&... keys) -> etl::set<TKey, sizeof...(T), TKeyCompare>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<T>(keys)...} };
}
#endif

View File

@ -237,6 +237,9 @@ namespace etl
using type = typename private_nth_type::nth_type_helper<N, TTypes...>::type;
};
template <size_t N, typename... TTypes>
using nth_type_t = typename nth_type<N, TTypes...>::type;
#else
//***************************************************************************

View File

@ -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<typename...>
struct common_type

View File

@ -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 <typename... T>
unordered_map(T...) -> unordered_map<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>;
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename... TPairs>
unordered_map(TPairs...) -> unordered_map<typename etl::nth_type_t<0, TPairs...>::first_type,
typename etl::nth_type_t<0, TPairs...>::second_type,
sizeof...(TPairs)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_unordered_map(T... t) -> etl::unordered_map<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TMapped, typename... TPairs>
constexpr auto make_unordered_map(TPairs&&... pairs) -> etl::unordered_map<TKey, TMapped, sizeof...(TPairs)>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<TPairs>(pairs)...} };
}
#endif
}

View File

@ -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 <typename... T>
unordered_multimap(T...) ->unordered_multimap<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>;
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename... TPairs>
unordered_multimap(TPairs...) -> unordered_multimap<typename etl::nth_type_t<0, TPairs...>::first_type,
typename etl::nth_type_t<0, TPairs...>::second_type,
sizeof...(TPairs)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_unordered_multimap(T... t) -> etl::unordered_multimap<typename etl::common_type_t<typename T::first_type...>,
typename etl::common_type_t<typename T::second_type...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename TMapped, typename... TPairs>
constexpr auto make_unordered_multimap(TPairs&&... pairs) -> etl::unordered_multimap<TKey, TMapped, sizeof...(TPairs)>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<TPairs>(pairs)...} };
}
#endif
}

View File

@ -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 <typename... T>
unordered_multiset(T...) -> unordered_multiset<typename etl::common_type_t<T...>,
sizeof...(T)>;
unordered_multiset(T...) -> unordered_multiset<etl::nth_type_t<0, T...>, sizeof...(T)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_unordered_multiset(T... t) -> etl::unordered_multiset<typename etl::common_type_t<T...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename... T>
constexpr auto make_unordered_multiset(T&&... keys) -> etl::unordered_multiset<TKey, sizeof...(T)>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<T>(keys)...} };
}
#endif
}

View File

@ -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 <typename... T>
unordered_set(T...) -> unordered_set<typename etl::common_type_t<T...>,
sizeof...(T)>;
unordered_set(T...) -> unordered_set<etl::nth_type_t<0, T...>, sizeof...(T)>;
#endif
//*************************************************************************
/// Make
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
template <typename... T>
constexpr auto make_unordered_set(T... t) -> etl::unordered_set<typename etl::common_type_t<T...>,
sizeof...(T)>
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
template <typename TKey, typename... T>
constexpr auto make_unordered_set(T&&... keys) -> etl::unordered_set<TKey, sizeof...(T)>
{
return { { etl::forward<T>(t)... } };
return { {etl::forward<T>(keys)...} };
}
#endif
}

View File

@ -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<char>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
using Type = std::remove_reference_t<decltype(data[0])>;
CHECK((std::is_same_v<long, Type>));
CHECK((std::is_same_v<char, Type>));
CHECK_EQUAL(0, data[0]);
CHECK_EQUAL(1, data[1]);

View File

@ -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<decltype(data[0])>;
CHECK((std::is_same_v<long, Type>));
auto data = etl::make_deque<int>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
CHECK_EQUAL(0, data[0]);
CHECK_EQUAL(1, data[1]);

View File

@ -1289,7 +1289,7 @@ namespace
{
using Pair = ETL_OR_STD::pair<const int, NDC>;
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<const int, NDC>(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);

View File

@ -1099,7 +1099,7 @@ namespace
{
using Pair = ETL_OR_STD::pair<const int, NDC>;
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<const int, NDC>(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);

View File

@ -1055,9 +1055,7 @@ namespace
#if ETL_USING_INITIALIZER_LIST
TEST(test_make_flat_multiset)
{
using Pair = ETL_OR_STD::pair<const int, NDC>;
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>(NDC("A"), NDC("B"), NDC("B2"), NDC("C"), NDC("D"), NDC("E"), NDC("F"));
auto v = *data.begin();
using Type = decltype(v);

View File

@ -984,9 +984,7 @@ namespace
#if ETL_USING_INITIALIZER_LIST
TEST(test_make_flat_set)
{
using Pair = ETL_OR_STD::pair<const int, NDC>;
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>(NDC("A"), NDC("B"), NDC("C"), NDC("D"), NDC("E"), NDC("F"));
auto v = *data.begin();
using Type = decltype(v);

View File

@ -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>(ItemNDC("A"), ItemNDC("B"), ItemNDC("C"), ItemNDC("D"), ItemNDC("E"), ItemNDC("F"));
auto v = *data.begin();
using Type = decltype(v);

View File

@ -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>(ItemNDC("A"), ItemNDC("B"), ItemNDC("C"), ItemNDC("D"), ItemNDC("E"), ItemNDC("F"));
auto v = *data.begin();
using Type = decltype(v);

View File

@ -1286,7 +1286,7 @@ namespace
{
using Pair = std::pair<const std::string, int>;
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<const std::string, int>;
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<std::string, int, std::less<std::string>>(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);

View File

@ -1275,11 +1275,11 @@ namespace
//*************************************************************************
#if ETL_USING_INITIALIZER_LIST
TEST(test_make_map)
TEST(test_make_multimap)
{
using Pair = ETL_OR_STD::pair<const std::string, int>;
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<std::string, int, std::less<std::string>>(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);

View File

@ -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);

View File

@ -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);

View File

@ -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<char>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
using Type = std::remove_reference_t<decltype(data[0])>;
CHECK((std::is_same_v<long, Type>));
CHECK((std::is_same_v<int, Type>));
CHECK_EQUAL(0, data[0]);
CHECK_EQUAL(1, data[1]);

View File

@ -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<decltype(data[0])>;
CHECK((std::is_same_v<const long*, Type>));
auto data = etl::make_vector<const int*>( &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]);