mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 14:49:53 +08:00
Merge branch 'feature/cpp11-make-functions-for-containers' into development
This commit is contained in:
commit
5173b18ab1
@ -43,6 +43,7 @@ SOFTWARE.
|
||||
#include "parameter_type.h"
|
||||
#include "static_assert.h"
|
||||
#include "error_handler.h"
|
||||
#include "nth_type.h"
|
||||
|
||||
///\defgroup array array
|
||||
/// A replacement for std::array if you haven't got C++0x11.
|
||||
@ -556,19 +557,20 @@ namespace etl
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename T, typename... Ts>
|
||||
array(T, Ts...)
|
||||
-> array<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
template <typename... T>
|
||||
array(T...) -> array<typename etl::common_type<T...>::type, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//#if ETL_CPP11_SUPPORTED
|
||||
// template <typename... T>
|
||||
// constexpr auto make_array(T&&... t)
|
||||
// -> etl::array<std::common_type_t<T...>, sizeof...(T)>
|
||||
// {
|
||||
// return { { etl::forward<T>(t)... } };
|
||||
// }
|
||||
//#endif
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename T, typename... TValues>
|
||||
constexpr auto make_array(TValues&&... values) -> etl::array<T, sizeof...(TValues)>
|
||||
{
|
||||
return { { etl::forward<T>(values)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Overloaded swap for etl::array<T, SIZE>
|
||||
|
||||
@ -1062,7 +1062,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
|
||||
@ -2381,7 +2381,7 @@ namespace etl
|
||||
this->assign(n, value);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -2453,10 +2453,20 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
deque(T, Ts...)
|
||||
->deque<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
deque(T...) -> deque<typename etl::common_type<T...>::type, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename T, typename... TValues>
|
||||
constexpr auto make_deque(TValues&&... values) -> etl::deque<T, sizeof...(TValues)>
|
||||
{
|
||||
return { { etl::forward<T>(values)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -35,6 +35,7 @@ SOFTWARE.
|
||||
#include "reference_flat_map.h"
|
||||
#include "pool.h"
|
||||
#include "placement_new.h"
|
||||
#include "nth_type.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
@ -943,7 +944,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -1004,13 +1005,23 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
flat_map(T, Ts...)
|
||||
->flat_map<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), typename T::first_type>,
|
||||
etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), typename T::second_type>,
|
||||
1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
#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_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<TPairs>(pairs)...} };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -36,6 +36,7 @@ SOFTWARE.
|
||||
#include "pool.h"
|
||||
#include "utility.h"
|
||||
#include "placement_new.h"
|
||||
#include "nth_type.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
@ -846,7 +847,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -907,13 +908,23 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
flat_multimap(T, Ts...)
|
||||
->flat_multimap<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), typename T::first_type>,
|
||||
etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), typename T::second_type>,
|
||||
1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
#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_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<TPairs>(pairs)...} };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -35,6 +35,7 @@ SOFTWARE.
|
||||
#include "reference_flat_multiset.h"
|
||||
#include "pool.h"
|
||||
#include "placement_new.h"
|
||||
#include "nth_type.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()
|
||||
@ -798,7 +799,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -859,11 +860,21 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
flat_multiset(T, Ts...)
|
||||
->flat_multiset<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
flat_multiset(T...) -> flat_multiset<etl::nth_type_t<0, T...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#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>(keys)...} };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -35,6 +35,7 @@ SOFTWARE.
|
||||
#include "reference_flat_set.h"
|
||||
#include "pool.h"
|
||||
#include "placement_new.h"
|
||||
#include "nth_type.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
@ -883,7 +884,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -944,11 +945,21 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
flat_set(T, Ts...)
|
||||
->flat_set<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
flat_set(T...) -> flat_set<etl::nth_type_t<0, T...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#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>(keys)...} };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -1664,7 +1664,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -1718,10 +1718,20 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
forward_list(T, Ts...)
|
||||
->forward_list<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
forward_list(T...) ->forward_list<typename etl::common_type_t<T...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#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)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
@ -1825,7 +1835,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
|
||||
@ -2022,6 +2022,63 @@ namespace etl
|
||||
inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable<T>::value;
|
||||
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
// primary template (used for zero types)
|
||||
template<class...>
|
||||
struct common_type {};
|
||||
|
||||
//////// one type
|
||||
template <class T>
|
||||
struct common_type<T> : common_type<T, T> {};
|
||||
|
||||
namespace detail {
|
||||
template<class...>
|
||||
using void_t = void;
|
||||
|
||||
template<class T1, class T2>
|
||||
using conditional_result_t = decltype(false ? std::declval<T1>() : std::declval<T2>());
|
||||
|
||||
template<class, class, class = void>
|
||||
struct decay_conditional_result {};
|
||||
template<class T1, class T2>
|
||||
struct decay_conditional_result<T1, T2, void_t<conditional_result_t<T1, T2>>>
|
||||
: std::decay<conditional_result_t<T1, T2>> {};
|
||||
|
||||
template<class T1, class T2, class = void>
|
||||
struct common_type_2_impl : decay_conditional_result<const T1&, const T2&> {};
|
||||
|
||||
// C++11 implementation:
|
||||
// template<class, class, class = void>
|
||||
// struct common_type_2_impl {};
|
||||
|
||||
template<class T1, class T2>
|
||||
struct common_type_2_impl<T1, T2, void_t<conditional_result_t<T1, T2>>>
|
||||
: decay_conditional_result<T1, T2> {};
|
||||
}
|
||||
|
||||
//////// two types
|
||||
template<class T1, class T2>
|
||||
struct common_type<T1, T2>
|
||||
: std::conditional<std::is_same<T1, typename std::decay<T1>::type>::value&&
|
||||
std::is_same<T2, typename std::decay<T2>::type>::value,
|
||||
detail::common_type_2_impl<T1, T2>,
|
||||
common_type<typename std::decay<T2>::type,
|
||||
typename std::decay<T2>::type>>::type{};
|
||||
|
||||
//////// 3+ types
|
||||
namespace detail {
|
||||
template<class AlwaysVoid, class T1, class T2, class...R>
|
||||
struct common_type_multi_impl {};
|
||||
template<class T1, class T2, class...R>
|
||||
struct common_type_multi_impl<void_t<typename common_type<T1, T2>::type>, T1, T2, R...>
|
||||
: common_type<typename common_type<T1, T2>::type, R...> {};
|
||||
}
|
||||
|
||||
template<class T1, class T2, class... R>
|
||||
struct common_type<T1, T2, R...>
|
||||
: detail::common_type_multi_impl<void, T1, T2, R...> {};
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // ETL_TYPE_TRAITS_INCLUDED
|
||||
|
||||
@ -1323,7 +1323,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
@ -1457,7 +1457,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
|
||||
@ -2106,7 +2106,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -2151,11 +2151,22 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
list(T, Ts...)
|
||||
->list<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
list(T...) -> list<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_list(T... t) -> etl::list<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// A templated list implementation that uses a fixed size buffer.
|
||||
@ -2270,7 +2281,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
|
||||
@ -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 "nth_type.h"
|
||||
#include "parameter_type.h"
|
||||
#include "iterator.h"
|
||||
#include "utility.h"
|
||||
@ -2214,7 +2215,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
@ -2279,13 +2280,23 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
map(T, Ts...)
|
||||
->map<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 && 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_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<TPairs>(pairs)...} };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
|
||||
@ -530,7 +530,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//********************************************
|
||||
// Initializer_list constructor.
|
||||
//********************************************
|
||||
|
||||
@ -43,6 +43,7 @@ SOFTWARE.
|
||||
#include "debug_count.h"
|
||||
#include "nullptr.h"
|
||||
#include "type_traits.h"
|
||||
#include "nth_type.h"
|
||||
#include "parameter_type.h"
|
||||
#include "iterator.h"
|
||||
#include "utility.h"
|
||||
@ -2076,7 +2077,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
@ -2138,13 +2139,23 @@ 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 && 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_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<TPairs>(pairs)...} };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
|
||||
@ -44,6 +44,7 @@ SOFTWARE.
|
||||
#include "debug_count.h"
|
||||
#include "nullptr.h"
|
||||
#include "type_traits.h"
|
||||
#include "nth_type.h"
|
||||
#include "utility.h"
|
||||
#include "placement_new.h"
|
||||
|
||||
@ -2057,7 +2058,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
@ -2121,11 +2122,21 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
multiset(T, Ts...)
|
||||
->multiset<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
multiset(T...) -> multiset<etl::nth_type_t<0, T...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#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>(keys)...} };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
|
||||
66
include/etl/nth_type.h
Normal file
66
include/etl/nth_type.h
Normal file
@ -0,0 +1,66 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
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
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_NTH_TYPE_INCLUDED
|
||||
#define ETL_NTH_TYPE_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
//***************************************************************************
|
||||
// nth_type
|
||||
//***************************************************************************
|
||||
namespace private_nth_type
|
||||
{
|
||||
template <size_t N, typename T1, typename... TRest>
|
||||
struct nth_type_helper
|
||||
{
|
||||
using type = typename nth_type_helper<N - 1U, TRest...>::type;
|
||||
};
|
||||
|
||||
template <size_t N, typename T1>
|
||||
struct nth_type_helper<N, T1>
|
||||
{
|
||||
using type = T1;
|
||||
};
|
||||
}
|
||||
|
||||
template <size_t N, typename... TTypes>
|
||||
struct nth_type
|
||||
{
|
||||
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;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -211,6 +211,14 @@ SOFTWARE.
|
||||
#define ETL_CONSTINIT
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
// Sort out namespaces for STL/No STL options.
|
||||
#include "private/choose_namespace.h"
|
||||
|
||||
|
||||
@ -569,7 +569,7 @@ namespace etl
|
||||
operation = operation_type<type, etl::is_copy_constructible<type>::value, etl::is_move_constructible<type>::value>::do_operation;
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//***************************************************************************
|
||||
/// Construct from type, initializer_list and arguments.
|
||||
//***************************************************************************
|
||||
|
||||
@ -38,6 +38,7 @@ SOFTWARE.
|
||||
#include "error_handler.h"
|
||||
#include "debug_count.h"
|
||||
#include "type_traits.h"
|
||||
#include "nth_type.h"
|
||||
#include "parameter_type.h"
|
||||
#include "exception.h"
|
||||
#include "static_assert.h"
|
||||
@ -962,6 +963,26 @@ namespace etl
|
||||
etl::vector<node_t*, MAX_SIZE> lookup;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#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_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<TPairs>(pairs)...} };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -39,6 +39,7 @@ SOFTWARE.
|
||||
#include "debug_count.h"
|
||||
#include "vector.h"
|
||||
#include "iterator.h"
|
||||
#include "nth_type.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -858,6 +859,27 @@ namespace etl
|
||||
// The vector that stores pointers to the nodes.
|
||||
etl::vector<node_t*, MAX_SIZE> lookup;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#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_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<TPairs>(pairs)...} };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -39,8 +39,8 @@ SOFTWARE.
|
||||
#include "iterator.h"
|
||||
#include "functional.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include "type_traits.h"
|
||||
#include "nth_type.h"
|
||||
#include "vector.h"
|
||||
#include "pool.h"
|
||||
#include "error_handler.h"
|
||||
@ -840,6 +840,25 @@ namespace etl
|
||||
etl::vector<value_type*, MAX_SIZE> lookup;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
reference_flat_multiset(T...)->reference_flat_multiset<etl::nth_type_t<0, T...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#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>(keys)...} };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the first reference_flat_multiset.
|
||||
|
||||
@ -39,8 +39,8 @@ SOFTWARE.
|
||||
#include "iterator.h"
|
||||
#include "functional.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include "type_traits.h"
|
||||
#include "nth_type.h"
|
||||
#include "pool.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
@ -824,6 +824,25 @@ namespace etl
|
||||
etl::vector<value_type*, MAX_SIZE> lookup;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
reference_flat_set(T...) -> reference_flat_set<etl::nth_type_t<0, T...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#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>(keys)...} };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the first reference_flat_set.
|
||||
|
||||
@ -47,6 +47,7 @@ SOFTWARE.
|
||||
#include "iterator.h"
|
||||
#include "functional.h"
|
||||
#include "placement_new.h"
|
||||
#include "nth_type.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
@ -2140,7 +2141,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
@ -2203,11 +2204,21 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
set(T, Ts...)
|
||||
->set<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
set(T...) -> set<etl::nth_type_t<0, T...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#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>(keys)...} };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
|
||||
@ -154,7 +154,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -360,7 +360,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
|
||||
@ -114,10 +114,8 @@ namespace etl
|
||||
static_assert(!(etl::is_same<nulltype, type>::value), "Invalid id");
|
||||
};
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <int ID>
|
||||
using type_from_id_t = typename type_from_id<ID>::type;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@ -210,11 +208,9 @@ namespace etl
|
||||
static_assert(!etl::is_same<type, nulltype>::value, "Type match not found");
|
||||
};
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
// Template alias.
|
||||
template <typename T>
|
||||
using type_from_type_t = typename type_from_type<T>::type;
|
||||
#endif
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
@ -79,12 +79,16 @@ namespace etl
|
||||
using type = typename type_select_helper<ID, 0, TTypes...>::type;
|
||||
};
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <size_t ID>
|
||||
using select_t = typename select<ID>::type;
|
||||
#endif
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
// Select type alias
|
||||
//***************************************************************************
|
||||
template <size_t N, typename... TTypes>
|
||||
using type_select_t = typename etl::type_select<TTypes...>:: template select_t<N>;
|
||||
|
||||
#else
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -2014,6 +2014,94 @@ namespace etl
|
||||
template <typename T>
|
||||
inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable<T>::value;
|
||||
|
||||
#endif
|
||||
|
||||
//*********************************************
|
||||
// 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<typename...>
|
||||
struct common_type
|
||||
{
|
||||
};
|
||||
|
||||
//***********************************
|
||||
// One type
|
||||
template <typename T>
|
||||
struct common_type<T> : common_type<T, T>
|
||||
{
|
||||
};
|
||||
|
||||
namespace private_common_type
|
||||
{
|
||||
template <typename...>
|
||||
using void_t = void;
|
||||
|
||||
template <typename T1, typename T2>
|
||||
using conditional_result_t = decltype(false ? declval<T1>() : declval<T2>());
|
||||
|
||||
template <typename, typename, typename = void>
|
||||
struct decay_conditional_result
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct decay_conditional_result<T1, T2, void_t<conditional_result_t<T1, T2>>>
|
||||
: etl::decay<conditional_result_t<T1, T2>>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename = void>
|
||||
struct common_type_2_impl : decay_conditional_result<const T1&, const T2&>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct common_type_2_impl<T1, T2, void_t<conditional_result_t<T1, T2>>>
|
||||
: decay_conditional_result<T1, T2>
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
//***********************************
|
||||
// Two types
|
||||
template <typename T1, typename T2>
|
||||
struct common_type<T1, T2>
|
||||
: etl::conditional<etl::is_same<T1, typename etl::decay<T1>::type>::value && etl::is_same<T2, typename etl::decay<T2>::type>::value,
|
||||
private_common_type::common_type_2_impl<T1, T2>,
|
||||
common_type<typename etl::decay<T2>::type,
|
||||
typename etl::decay<T2>::type>>::type
|
||||
{
|
||||
};
|
||||
|
||||
//***********************************
|
||||
// Three or more types
|
||||
namespace private_common_type
|
||||
{
|
||||
template <typename AlwaysVoid, typename T1, typename T2, typename... TRest>
|
||||
struct common_type_multi_impl
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename... TRest>
|
||||
struct common_type_multi_impl<void_t<typename common_type<T1, T2>::type>, T1, T2, TRest...>
|
||||
: common_type<typename common_type<T1, T2>::type, TRest...>
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename... TRest>
|
||||
struct common_type<T1, T2, TRest...>
|
||||
: private_common_type::common_type_multi_impl<void, T1, T2, TRest...>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
using common_type_t = typename common_type<T...>::type;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -343,7 +343,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
|
||||
@ -152,7 +152,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -343,7 +343,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
|
||||
@ -43,6 +43,7 @@ SOFTWARE.
|
||||
#include "intrusive_forward_list.h"
|
||||
#include "hash.h"
|
||||
#include "type_traits.h"
|
||||
#include "nth_type.h"
|
||||
#include "parameter_type.h"
|
||||
#include "nullptr.h"
|
||||
#include "vector.h"
|
||||
@ -1490,8 +1491,8 @@ namespace etl
|
||||
///\return <b>true</b> if the arrays are equal, otherwise <b>false</b>
|
||||
///\ingroup unordered_map
|
||||
//***************************************************************************
|
||||
template <typename TKey, typename TMapped, typename TKeyCompare>
|
||||
bool operator ==(const etl::iunordered_map<TKey, TMapped, TKeyCompare>& lhs, const etl::iunordered_map<TKey, TMapped, TKeyCompare>& rhs)
|
||||
template <typename TKey, typename T, typename TKeyCompare>
|
||||
bool operator ==(const etl::iunordered_map<TKey, T, TKeyCompare>& lhs, const etl::iunordered_map<TKey, T, TKeyCompare>& rhs)
|
||||
{
|
||||
return (lhs.size() == rhs.size()) && etl::equal(lhs.begin(), lhs.end(), rhs.begin());
|
||||
}
|
||||
@ -1503,8 +1504,8 @@ namespace etl
|
||||
///\return <b>true</b> if the arrays are not equal, otherwise <b>false</b>
|
||||
///\ingroup unordered_map
|
||||
//***************************************************************************
|
||||
template <typename TKey, typename TMapped, typename TKeyCompare>
|
||||
bool operator !=(const etl::iunordered_map<TKey, TMapped, TKeyCompare>& lhs, const etl::iunordered_map<TKey, TMapped, TKeyCompare>& rhs)
|
||||
template <typename TKey, typename T, typename TKeyCompare>
|
||||
bool operator !=(const etl::iunordered_map<TKey, T, TKeyCompare>& lhs, const etl::iunordered_map<TKey, T, TKeyCompare>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
@ -1569,7 +1570,7 @@ namespace etl
|
||||
base::assign(first_, last_);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -1631,12 +1632,22 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
unordered_map(T, Ts...)
|
||||
->unordered_map<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), typename T::first_type>,
|
||||
typename T::second_type,
|
||||
1U + sizeof...(Ts)>;
|
||||
#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_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename TKey, typename T, typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>, typename... TPairs>
|
||||
constexpr auto make_unordered_map(TPairs&&... pairs) -> etl::unordered_map<TKey, T, sizeof...(TPairs), sizeof...(TPairs), THash, TKeyEqual>
|
||||
{
|
||||
return { {etl::forward<TPairs>(pairs)...} };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ SOFTWARE.
|
||||
#include "intrusive_forward_list.h"
|
||||
#include "hash.h"
|
||||
#include "type_traits.h"
|
||||
#include "nth_type.h"
|
||||
#include "parameter_type.h"
|
||||
#include "nullptr.h"
|
||||
#include "pool.h"
|
||||
@ -1480,7 +1481,7 @@ namespace etl
|
||||
base::assign(first_, last_);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -1542,12 +1543,22 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
unordered_multimap(T, Ts...)
|
||||
->unordered_multimap<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), typename T::first_type>,
|
||||
typename T::second_type,
|
||||
1U + sizeof...(Ts)>;
|
||||
#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_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename TKey, typename T, typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>, typename... TPairs>
|
||||
constexpr auto make_unordered_multimap(TPairs&&... pairs) -> etl::unordered_multimap<TKey, T, sizeof...(TPairs), sizeof...(TPairs), THash, TKeyEqual>
|
||||
{
|
||||
return { {etl::forward<TPairs>(pairs)...} };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ SOFTWARE.
|
||||
#include "intrusive_forward_list.h"
|
||||
#include "hash.h"
|
||||
#include "type_traits.h"
|
||||
#include "nth_type.h"
|
||||
#include "parameter_type.h"
|
||||
#include "nullptr.h"
|
||||
#include "error_handler.h"
|
||||
@ -1466,7 +1467,7 @@ namespace etl
|
||||
base::assign(first_, last_);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -1528,10 +1529,20 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
unordered_multiset(T, Ts...)
|
||||
->unordered_multiset<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
unordered_multiset(T...) -> unordered_multiset<etl::nth_type_t<0, T...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename TKey, typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>, typename... T>
|
||||
constexpr auto make_unordered_multiset(T&&... keys) -> etl::unordered_multiset<TKey, sizeof...(T), sizeof...(T), THash, TKeyEqual>
|
||||
{
|
||||
return { {etl::forward<T>(keys)...} };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ SOFTWARE.
|
||||
#include "intrusive_forward_list.h"
|
||||
#include "hash.h"
|
||||
#include "type_traits.h"
|
||||
#include "nth_type.h"
|
||||
#include "parameter_type.h"
|
||||
#include "nullptr.h"
|
||||
#include "error_handler.h"
|
||||
@ -1464,7 +1465,7 @@ namespace etl
|
||||
base::assign(first_, last_);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -1526,10 +1527,20 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
unordered_set(T, Ts...)
|
||||
->unordered_set<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
unordered_set(T...) -> unordered_set<etl::nth_type_t<0, T...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
template <typename TKey, typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>, typename... T>
|
||||
constexpr auto make_unordered_set(T&&... keys) -> etl::unordered_set<TKey, sizeof...(T), sizeof...(T), THash, TKeyEqual>
|
||||
{
|
||||
return { {etl::forward<T>(keys)...} };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1185,7 +1185,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
@ -1294,10 +1294,20 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
vector(T, Ts...)
|
||||
->vector<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
vector(T...) -> vector<typename etl::common_type_t<T...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_vector(T... t) -> etl::vector<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
@ -1356,7 +1366,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
@ -1586,10 +1596,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
vector(T*, Ts*...)
|
||||
->vector<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T*>, 1U + sizeof...(Ts)>;
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
vector(T*...) -> vector<typename etl::common_type_t<T*...>, sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <typename... T>
|
||||
constexpr auto make_vector(T*... t) -> etl::vector<typename etl::common_type_t<T*...>, sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T*>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
@ -1648,7 +1665,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
|
||||
@ -152,7 +152,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -343,7 +343,7 @@ namespace etl
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
|
||||
@ -186,6 +186,7 @@ target_sources(t98 PRIVATE etl_profile.h
|
||||
../murmur3.h.t.cpp
|
||||
../mutex.h.t.cpp
|
||||
../negative.h.t.cpp
|
||||
../nth_type.h.t.cpp
|
||||
../nullptr.h.t.cpp
|
||||
../null_type.h.t.cpp
|
||||
../numeric.h.t.cpp
|
||||
|
||||
@ -186,6 +186,7 @@ target_sources(t11 PRIVATE etl_profile.h
|
||||
../murmur3.h.t.cpp
|
||||
../mutex.h.t.cpp
|
||||
../negative.h.t.cpp
|
||||
../nth_type.h.t.cpp
|
||||
../nullptr.h.t.cpp
|
||||
../null_type.h.t.cpp
|
||||
../numeric.h.t.cpp
|
||||
|
||||
@ -186,6 +186,7 @@ target_sources(t14 PRIVATE etl_profile.h
|
||||
../murmur3.h.t.cpp
|
||||
../mutex.h.t.cpp
|
||||
../negative.h.t.cpp
|
||||
../nth_type.h.t.cpp
|
||||
../nullptr.h.t.cpp
|
||||
../null_type.h.t.cpp
|
||||
../numeric.h.t.cpp
|
||||
|
||||
@ -186,6 +186,7 @@ target_sources(t17 PRIVATE etl_profile.h
|
||||
../murmur3.h.t.cpp
|
||||
../mutex.h.t.cpp
|
||||
../negative.h.t.cpp
|
||||
../nth_type.h.t.cpp
|
||||
../nullptr.h.t.cpp
|
||||
../null_type.h.t.cpp
|
||||
../numeric.h.t.cpp
|
||||
|
||||
29
test/sanity-check/nth_type.h.t.cpp
Normal file
29
test/sanity-check/nth_type.h.t.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2021 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include <etl/nth_type.h>
|
||||
@ -28,16 +28,21 @@ SOFTWARE.
|
||||
|
||||
#include "unit_test_framework.h"
|
||||
|
||||
#include "data.h"
|
||||
|
||||
#include "etl/array.h"
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
#include "etl/integral_limits.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
using Moveable = TestDataM<int>;
|
||||
|
||||
SUITE(test_array)
|
||||
{
|
||||
static const size_t SIZE = 10UL;
|
||||
@ -646,12 +651,91 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//TEST(test_make_array)
|
||||
//{
|
||||
// auto data = etl::make_array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_array_template_deduction)
|
||||
{
|
||||
etl::array data{ char(0), short(1), int(2), long(3), 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
// CHECK_EQUAL(5, data[5]);
|
||||
//}
|
||||
using Type = std::remove_reference_t<decltype(data[0])>;
|
||||
CHECK((std::is_same_v<long, Type>));
|
||||
|
||||
CHECK_EQUAL(0, data[0]);
|
||||
CHECK_EQUAL(1, data[1]);
|
||||
CHECK_EQUAL(2, data[2]);
|
||||
CHECK_EQUAL(3, data[3]);
|
||||
CHECK_EQUAL(4, data[4]);
|
||||
CHECK_EQUAL(5, data[5]);
|
||||
CHECK_EQUAL(6, data[6]);
|
||||
CHECK_EQUAL(7, data[7]);
|
||||
CHECK_EQUAL(8, data[8]);
|
||||
CHECK_EQUAL(9, data[9]);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_array_template_deduction_for_movable)
|
||||
{
|
||||
etl::array data{ Moveable(0), Moveable(1), Moveable(2), Moveable(3), Moveable(4), Moveable(5), Moveable(6), Moveable(7), Moveable(8), Moveable(9) };
|
||||
|
||||
using Type = std::remove_reference_t<decltype(data[0])>;
|
||||
CHECK((std::is_same_v<Moveable, Type>));
|
||||
|
||||
CHECK_EQUAL(Moveable(0), data[0]);
|
||||
CHECK_EQUAL(Moveable(1), data[1]);
|
||||
CHECK_EQUAL(Moveable(2), data[2]);
|
||||
CHECK_EQUAL(Moveable(3), data[3]);
|
||||
CHECK_EQUAL(Moveable(4), data[4]);
|
||||
CHECK_EQUAL(Moveable(5), data[5]);
|
||||
CHECK_EQUAL(Moveable(6), data[6]);
|
||||
CHECK_EQUAL(Moveable(7), data[7]);
|
||||
CHECK_EQUAL(Moveable(8), data[8]);
|
||||
CHECK_EQUAL(Moveable(9), data[9]);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_array)
|
||||
{
|
||||
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<char, Type>));
|
||||
|
||||
CHECK_EQUAL(0, data[0]);
|
||||
CHECK_EQUAL(1, data[1]);
|
||||
CHECK_EQUAL(2, data[2]);
|
||||
CHECK_EQUAL(3, data[3]);
|
||||
CHECK_EQUAL(4, data[4]);
|
||||
CHECK_EQUAL(5, data[5]);
|
||||
CHECK_EQUAL(6, data[6]);
|
||||
CHECK_EQUAL(7, data[7]);
|
||||
CHECK_EQUAL(8, data[8]);
|
||||
CHECK_EQUAL(9, data[9]);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_array_for_movable)
|
||||
{
|
||||
auto data = etl::make_array<Moveable>(Moveable(0), Moveable(1), Moveable(2), Moveable(3), Moveable(4), Moveable(5), Moveable(6), Moveable(7), Moveable(8), Moveable(9));
|
||||
|
||||
using Type = std::remove_reference_t<decltype(data[0])>;
|
||||
CHECK((std::is_same_v<Moveable, Type>));
|
||||
|
||||
CHECK_EQUAL(Moveable(0), data[0]);
|
||||
CHECK_EQUAL(Moveable(1), data[1]);
|
||||
CHECK_EQUAL(Moveable(2), data[2]);
|
||||
CHECK_EQUAL(Moveable(3), data[3]);
|
||||
CHECK_EQUAL(Moveable(4), data[4]);
|
||||
CHECK_EQUAL(Moveable(5), data[5]);
|
||||
CHECK_EQUAL(Moveable(6), data[6]);
|
||||
CHECK_EQUAL(Moveable(7), data[7]);
|
||||
CHECK_EQUAL(Moveable(8), data[8]);
|
||||
CHECK_EQUAL(Moveable(9), data[9]);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ namespace
|
||||
CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin()));
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_initializer_list)
|
||||
{
|
||||
@ -2008,5 +2008,46 @@ namespace
|
||||
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_deque_template_deduction)
|
||||
{
|
||||
etl::deque data{ 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>));
|
||||
|
||||
CHECK_EQUAL(0, data[0]);
|
||||
CHECK_EQUAL(1, data[1]);
|
||||
CHECK_EQUAL(2, data[2]);
|
||||
CHECK_EQUAL(3, data[3]);
|
||||
CHECK_EQUAL(4, data[4]);
|
||||
CHECK_EQUAL(5, data[5]);
|
||||
CHECK_EQUAL(6, data[6]);
|
||||
CHECK_EQUAL(7, data[7]);
|
||||
CHECK_EQUAL(8, data[8]);
|
||||
CHECK_EQUAL(9, data[9]);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_deque)
|
||||
{
|
||||
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]);
|
||||
CHECK_EQUAL(2, data[2]);
|
||||
CHECK_EQUAL(3, data[3]);
|
||||
CHECK_EQUAL(4, data[4]);
|
||||
CHECK_EQUAL(5, data[5]);
|
||||
CHECK_EQUAL(6, data[6]);
|
||||
CHECK_EQUAL(7, data[7]);
|
||||
CHECK_EQUAL(8, data[8]);
|
||||
CHECK_EQUAL(9, data[9]);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
@ -1261,5 +1261,47 @@ namespace
|
||||
|
||||
CHECK(initial1 != different);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_flat_map_template_deduction)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const int, NDC>;
|
||||
|
||||
etl::flat_map data{ 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);
|
||||
CHECK((std::is_same_v<Pair, Type>));
|
||||
|
||||
CHECK_EQUAL(NDC("A"), data.at(0));
|
||||
CHECK_EQUAL(NDC("B"), data.at(1));
|
||||
CHECK_EQUAL(NDC("C"), data.at(2));
|
||||
CHECK_EQUAL(NDC("D"), data.at(3));
|
||||
CHECK_EQUAL(NDC("E"), data.at(4));
|
||||
CHECK_EQUAL(NDC("F"), data.at(5));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_flat_map)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const int, NDC>;
|
||||
|
||||
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);
|
||||
CHECK((std::is_same_v<Pair, Type>));
|
||||
|
||||
CHECK_EQUAL(NDC("A"), data.at(0));
|
||||
CHECK_EQUAL(NDC("B"), data.at(1));
|
||||
CHECK_EQUAL(NDC("C"), data.at(2));
|
||||
CHECK_EQUAL(NDC("D"), data.at(3));
|
||||
CHECK_EQUAL(NDC("E"), data.at(4));
|
||||
CHECK_EQUAL(NDC("F"), data.at(5));
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -327,7 +327,7 @@ namespace
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
@ -1063,5 +1063,64 @@ namespace
|
||||
CHECK(compare_data.count(4) == data.count(4));
|
||||
CHECK(compare_data.count(5) == data.count(5));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_flat_multimap_template_deduction)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const int, NDC>;
|
||||
|
||||
etl::flat_multimap data{ 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);
|
||||
CHECK((std::is_same_v<Pair, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(NDC("A"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("B"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("B2"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("C"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("D"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("E"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("F"), itr->second);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_flat_multimap)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const int, NDC>;
|
||||
|
||||
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);
|
||||
CHECK((std::is_same_v<Pair, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(NDC("A"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("B"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("B2"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("C"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("D"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("E"), itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("F"), itr->second);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
@ -1020,5 +1020,63 @@ namespace
|
||||
CHECK_EQUAL(compare_data.count(N3), data.count(N3));
|
||||
CHECK_EQUAL(compare_data.count(N4), data.count(N4));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_flat_set_template_deduction)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const int, NDC>;
|
||||
|
||||
etl::flat_multiset data{ NDC("A"), NDC("B"), NDC("B2"), NDC("C"), NDC("D"), NDC("E"), NDC("F") };
|
||||
|
||||
auto v = *data.begin();
|
||||
using Type = decltype(v);
|
||||
CHECK((std::is_same_v<NDC, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(NDC("A"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("B"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("B2"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("C"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("D"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("E"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("F"), *itr);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_flat_multiset)
|
||||
{
|
||||
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);
|
||||
CHECK((std::is_same_v<NDC, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(NDC("A"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("B"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("B2"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("C"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("D"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("E"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("F"), *itr);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
@ -951,5 +951,59 @@ namespace
|
||||
|
||||
CHECK(initial1 != different);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_flat_set_template_deduction)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const int, NDC>;
|
||||
|
||||
etl::flat_set data{ NDC("A"), NDC("B"), NDC("C"), NDC("D"), NDC("E"), NDC("F") };
|
||||
|
||||
auto v = *data.begin();
|
||||
using Type = decltype(v);
|
||||
CHECK((std::is_same_v<NDC, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(NDC("A"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("B"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("C"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("D"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("E"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("F"), *itr);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_flat_set)
|
||||
{
|
||||
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);
|
||||
CHECK((std::is_same_v<NDC, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(NDC("A"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("B"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("C"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("D"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("E"), *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL(NDC("F"), *itr);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ namespace
|
||||
CHECK(are_equal);
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
@ -1349,5 +1349,47 @@ namespace
|
||||
CHECK(data1 < data3);
|
||||
CHECK(data3 > data1);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_forward_list_template_deduction)
|
||||
{
|
||||
etl::forward_list data{ ItemNDC("A"), ItemNDC("B"), ItemNDC("C"), ItemNDC("D"), ItemNDC("E"), ItemNDC("F") };
|
||||
|
||||
auto v = *data.begin();
|
||||
using Type = decltype(v);
|
||||
CHECK((std::is_same_v<ItemNDC, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(ItemNDC("A"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("B"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("C"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("D"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("E"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("F"), *itr++);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_forward_list)
|
||||
{
|
||||
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);
|
||||
CHECK((std::is_same_v<ItemNDC, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(ItemNDC("A"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("B"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("C"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("D"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("E"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("F"), *itr++);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ namespace
|
||||
CHECK(are_equal);
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
|
||||
@ -230,7 +230,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_initializer_list)
|
||||
{
|
||||
|
||||
@ -258,7 +258,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_initializer_list)
|
||||
{
|
||||
|
||||
@ -185,7 +185,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
@ -2027,5 +2027,47 @@ namespace
|
||||
CHECK_EQUAL(3U, (*itr++).value); // 3
|
||||
CHECK_EQUAL(4U, (*itr++).value); // 4
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_forward_list_template_deduction)
|
||||
{
|
||||
etl::list data{ ItemNDC("A"), ItemNDC("B"), ItemNDC("C"), ItemNDC("D"), ItemNDC("E"), ItemNDC("F") };
|
||||
|
||||
auto v = *data.begin();
|
||||
using Type = decltype(v);
|
||||
CHECK((std::is_same_v<ItemNDC, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(ItemNDC("A"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("B"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("C"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("D"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("E"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("F"), *itr++);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_list)
|
||||
{
|
||||
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);
|
||||
CHECK((std::is_same_v<ItemNDC, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(ItemNDC("A"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("B"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("C"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("D"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("E"), *itr++);
|
||||
CHECK_EQUAL(ItemNDC("F"), *itr++);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -237,7 +237,7 @@ namespace
|
||||
CHECK(pool.full());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
|
||||
@ -283,7 +283,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
@ -1224,60 +1224,102 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_compare_lower_upper_bound)
|
||||
{
|
||||
Data data(initial_data_even.begin(), initial_data_even.end());
|
||||
Compare_Data compare(initial_data_even.begin(), initial_data_even.end());
|
||||
Data data(initial_data_even.begin(), initial_data_even.end());
|
||||
Compare_Data compare(initial_data_even.begin(), initial_data_even.end());
|
||||
|
||||
std::vector<ETL_OR_STD::pair<std::string, int> > tab(test_data.begin(), test_data.end());
|
||||
std::vector<ETL_OR_STD::pair<std::string, int> > tab(test_data.begin(), test_data.end());
|
||||
|
||||
//make sure both data and compare contain same elements
|
||||
std::vector<ETL_OR_STD::pair<std::string, int> > data_elements(data.begin(), data.end());
|
||||
std::vector<ETL_OR_STD::pair<std::string, int> > compare_data_elements(compare.begin(), compare.end());
|
||||
//make sure both data and compare contain same elements
|
||||
std::vector<ETL_OR_STD::pair<std::string, int> > data_elements(data.begin(), data.end());
|
||||
std::vector<ETL_OR_STD::pair<std::string, int> > compare_data_elements(compare.begin(), compare.end());
|
||||
|
||||
CHECK(data_elements == compare_data_elements);
|
||||
CHECK(data_elements.size() == MAX_SIZE);
|
||||
CHECK(data_elements == compare_data_elements);
|
||||
CHECK(data_elements.size() == MAX_SIZE);
|
||||
|
||||
for(std::vector<ETL_OR_STD::pair<std::string, int> >::iterator it = tab.begin() ; it != tab.end() ; ++it)
|
||||
for(std::vector<ETL_OR_STD::pair<std::string, int> >::iterator it = tab.begin() ; it != tab.end() ; ++it)
|
||||
{
|
||||
std::string i = it->first;
|
||||
|
||||
//lower_bound
|
||||
CHECK((compare.lower_bound(i) == compare.end()) == (data.lower_bound(i) == data.end()));
|
||||
//if both end, or none
|
||||
if((compare.lower_bound(i) == compare.end()) == (data.lower_bound(i) == data.end()))
|
||||
{
|
||||
std::string i = it->first;
|
||||
//if both are not end
|
||||
if(compare.lower_bound(i) != compare.end())
|
||||
{
|
||||
CHECK((*compare.lower_bound(i)) == (*data.lower_bound(i)));
|
||||
}
|
||||
|
||||
//lower_bound
|
||||
CHECK((compare.lower_bound(i) == compare.end()) == (data.lower_bound(i) == data.end()));
|
||||
//if both end, or none
|
||||
if((compare.lower_bound(i) == compare.end()) == (data.lower_bound(i) == data.end()))
|
||||
{
|
||||
//if both are not end
|
||||
if(compare.lower_bound(i) != compare.end())
|
||||
{
|
||||
CHECK((*compare.lower_bound(i)) == (*data.lower_bound(i)));
|
||||
}
|
||||
ETL_OR_STD::pair<Compare_Data::const_iterator, Compare_Data::const_iterator> stlret = compare.equal_range(i);
|
||||
ETL_OR_STD::pair<Data::const_iterator, Data::const_iterator> etlret = data.equal_range(i);
|
||||
|
||||
ETL_OR_STD::pair<Compare_Data::const_iterator, Compare_Data::const_iterator> stlret = compare.equal_range(i);
|
||||
ETL_OR_STD::pair<Data::const_iterator, Data::const_iterator> etlret = data.equal_range(i);
|
||||
|
||||
CHECK((stlret.first == compare.end()) == (etlret.first == data.end()));
|
||||
if((stlret.first != compare.end()) && (etlret.first != data.end()))
|
||||
{
|
||||
CHECK((*stlret.first) == (*etlret.first));
|
||||
}
|
||||
CHECK((stlret.second == compare.end()) == (etlret.second == data.end()));
|
||||
if((stlret.second != compare.end()) && (etlret.second != data.end()))
|
||||
{
|
||||
CHECK((*stlret.second) == (*etlret.second));
|
||||
}
|
||||
}
|
||||
|
||||
//upper_bound
|
||||
CHECK((compare.upper_bound(i) == compare.end()) == (data.upper_bound(i) == data.end()));
|
||||
//if both end, or none
|
||||
if((compare.upper_bound(i) == compare.end()) == (data.upper_bound(i) == data.end()))
|
||||
{
|
||||
//if both are not end
|
||||
if(compare.upper_bound(i) != compare.end())
|
||||
{
|
||||
CHECK((*compare.upper_bound(i)) == (*data.upper_bound(i)));
|
||||
}
|
||||
}
|
||||
CHECK((stlret.first == compare.end()) == (etlret.first == data.end()));
|
||||
if((stlret.first != compare.end()) && (etlret.first != data.end()))
|
||||
{
|
||||
CHECK((*stlret.first) == (*etlret.first));
|
||||
}
|
||||
CHECK((stlret.second == compare.end()) == (etlret.second == data.end()));
|
||||
if((stlret.second != compare.end()) && (etlret.second != data.end()))
|
||||
{
|
||||
CHECK((*stlret.second) == (*etlret.second));
|
||||
}
|
||||
}
|
||||
|
||||
//upper_bound
|
||||
CHECK((compare.upper_bound(i) == compare.end()) == (data.upper_bound(i) == data.end()));
|
||||
//if both end, or none
|
||||
if((compare.upper_bound(i) == compare.end()) == (data.upper_bound(i) == data.end()))
|
||||
{
|
||||
//if both are not end
|
||||
if(compare.upper_bound(i) != compare.end())
|
||||
{
|
||||
CHECK((*compare.upper_bound(i)) == (*data.upper_bound(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_map_template_deduction)
|
||||
{
|
||||
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} };
|
||||
|
||||
auto v = *data.begin();
|
||||
using Type = decltype(v);
|
||||
CHECK((std::is_same_v<Pair, Type>));
|
||||
|
||||
CHECK_EQUAL(0, data.at("0"));
|
||||
CHECK_EQUAL(1, data.at("1"));
|
||||
CHECK_EQUAL(2, data.at("2"));
|
||||
CHECK_EQUAL(3, data.at("3"));
|
||||
CHECK_EQUAL(4, data.at("4"));
|
||||
CHECK_EQUAL(5, data.at("5"));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_map)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const std::string, int>;
|
||||
|
||||
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);
|
||||
CHECK((std::is_same_v<Pair, Type>));
|
||||
|
||||
CHECK_EQUAL(0, data.at("0"));
|
||||
CHECK_EQUAL(1, data.at("1"));
|
||||
CHECK_EQUAL(2, data.at("2"));
|
||||
CHECK_EQUAL(3, data.at("3"));
|
||||
CHECK_EQUAL(4, data.at("4"));
|
||||
CHECK_EQUAL(5, data.at("5"));
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
@ -1244,5 +1244,61 @@ namespace
|
||||
|
||||
CHECK(pass);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_multimap_template_deduction)
|
||||
{
|
||||
using Pair = std::pair<const std::string, int>;
|
||||
|
||||
etl::multimap 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);
|
||||
CHECK((std::is_same_v<Pair, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(0, itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(1, itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(2, itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(3, itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(4, itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(5, itr->second);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_multimap)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const std::string, int>;
|
||||
|
||||
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);
|
||||
CHECK((std::is_same_v<Pair, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL(0, itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(1, itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(2, itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(3, itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(4, itr->second);
|
||||
++itr;
|
||||
CHECK_EQUAL(5, itr->second);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
@ -1250,5 +1250,57 @@ namespace
|
||||
|
||||
CHECK(pass);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
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") };
|
||||
|
||||
auto v = *data.begin();
|
||||
using Type = decltype(v);
|
||||
CHECK((std::is_same_v<std::string, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL("A", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("B", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("C", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("D", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("E", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("F", *itr);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_multiset)
|
||||
{
|
||||
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);
|
||||
CHECK((std::is_same_v<std::string, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL("A", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("B", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("C", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("D", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("E", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("F", *itr);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ namespace
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_initializer_list)
|
||||
{
|
||||
@ -1197,5 +1197,57 @@ namespace
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_set_template_deduction)
|
||||
{
|
||||
etl::set data{ 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);
|
||||
CHECK((std::is_same_v<std::string, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL("A", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("B", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("C", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("D", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("E", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("F", *itr);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_set)
|
||||
{
|
||||
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);
|
||||
CHECK((std::is_same_v<std::string, Type>));
|
||||
|
||||
decltype(data)::const_iterator itr = data.begin();
|
||||
|
||||
CHECK_EQUAL("A", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("B", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("C", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("D", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("E", *itr);
|
||||
++itr;
|
||||
CHECK_EQUAL("F", *itr);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_construct_initializer_list)
|
||||
{
|
||||
|
||||
@ -483,7 +483,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_construct_initializer_list)
|
||||
{
|
||||
|
||||
@ -376,7 +376,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_construct_initializer_list)
|
||||
{
|
||||
|
||||
@ -483,7 +483,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_construct_initializer_list)
|
||||
{
|
||||
|
||||
@ -376,7 +376,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_construct_initializer_list)
|
||||
{
|
||||
|
||||
@ -483,7 +483,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_construct_initializer_list)
|
||||
{
|
||||
|
||||
@ -376,7 +376,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_construct_initializer_list)
|
||||
{
|
||||
|
||||
@ -483,7 +483,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_construct_initializer_list)
|
||||
{
|
||||
|
||||
@ -160,7 +160,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_initializer_list)
|
||||
{
|
||||
@ -1303,5 +1303,27 @@ namespace
|
||||
bool is_same = std::equal(expected.begin(), expected.end(), data.begin());
|
||||
CHECK(is_same);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_vector)
|
||||
{
|
||||
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<int, Type>));
|
||||
|
||||
CHECK_EQUAL(0, data[0]);
|
||||
CHECK_EQUAL(1, data[1]);
|
||||
CHECK_EQUAL(2, data[2]);
|
||||
CHECK_EQUAL(3, data[3]);
|
||||
CHECK_EQUAL(4, data[4]);
|
||||
CHECK_EQUAL(5, data[5]);
|
||||
CHECK_EQUAL(6, data[6]);
|
||||
CHECK_EQUAL(7, data[7]);
|
||||
CHECK_EQUAL(8, data[8]);
|
||||
CHECK_EQUAL(9, data[9]);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_initializer_list)
|
||||
{
|
||||
|
||||
@ -186,7 +186,7 @@ namespace
|
||||
CHECK(!data.empty());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_initializer_list)
|
||||
{
|
||||
|
||||
@ -244,7 +244,7 @@ namespace
|
||||
CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin()));
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_initializer_list)
|
||||
{
|
||||
@ -1916,5 +1916,26 @@ namespace
|
||||
CHECK(i1 == *i2);
|
||||
CHECK(&i1 == i2);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_vector)
|
||||
{
|
||||
const int values[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
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]);
|
||||
CHECK_EQUAL(2, *data[2]);
|
||||
CHECK_EQUAL(3, *data[3]);
|
||||
CHECK_EQUAL(4, *data[4]);
|
||||
CHECK_EQUAL(5, *data[5]);
|
||||
CHECK_EQUAL(6, *data[6]);
|
||||
CHECK_EQUAL(7, *data[7]);
|
||||
CHECK_EQUAL(8, *data[8]);
|
||||
CHECK_EQUAL(9, *data[9]);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ namespace
|
||||
CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin()));
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_initializer_list)
|
||||
{
|
||||
|
||||
@ -1822,6 +1822,7 @@
|
||||
<ClInclude Include="..\..\include\etl\mutex\mutex_cmsis_os2.h" />
|
||||
<ClInclude Include="..\..\include\etl\mutex\mutex_freertos.h" />
|
||||
<ClInclude Include="..\..\include\etl\negative.h" />
|
||||
<ClInclude Include="..\..\include\etl\nth_type.h" />
|
||||
<ClInclude Include="..\..\include\etl\overload.h" />
|
||||
<ClInclude Include="..\..\include\etl\placement_new.h" />
|
||||
<ClInclude Include="..\..\include\etl\null_type.h" />
|
||||
@ -5633,6 +5634,26 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Clang|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - Appveyor|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\nth_type.h.t.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Small Strings|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - Appveyor|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - No STL - Appveyor|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No Unit Tests|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - String Truncation Is Error|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Clang|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL - Force No Advanced|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force cpp03|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Checks|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force C++03|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\nullptr.h.t.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM|Win32'">true</ExcludedFromBuild>
|
||||
|
||||
@ -1161,6 +1161,9 @@
|
||||
<ClInclude Include="..\..\include\etl\multi_span.h">
|
||||
<Filter>ETL\Containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\nth_type.h">
|
||||
<Filter>ETL\Utilities</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\main.cpp">
|
||||
@ -3041,6 +3044,9 @@
|
||||
<ClCompile Include="..\sanity-check\multi_span.h.t.cpp">
|
||||
<Filter>Source Files\Sanity Checks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\nth_type.h.t.cpp">
|
||||
<Filter>Source Files\Sanity Checks</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\library.properties">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user