mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Added 'make' functions to construct containers
Added tests for 'make' and 'template deduction'
This commit is contained in:
parent
bb72ded2e2
commit
84974acbfa
@ -43,6 +43,7 @@ SOFTWARE.
|
||||
#include "parameter_type.h"
|
||||
#include "static_assert.h"
|
||||
#include "error_handler.h"
|
||||
#include "type_lookup.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>
|
||||
constexpr auto make_array(T&&... t) -> etl::array<typename etl::common_type_t<T...>, sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#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>
|
||||
constexpr auto make_deque(T&&... t) -> etl::deque<typename etl::common_type<T...>::type, sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -943,7 +943,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 +1004,25 @@ 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
|
||||
template <typename... T>
|
||||
flat_map(T...) -> flat_map<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_flat_map(T... t) -> etl::flat_map<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -846,7 +846,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 +907,25 @@ 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
|
||||
template <typename... T>
|
||||
flat_multimap(T...) -> flat_multimap<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_flat_multimap(T... t) -> etl::flat_multimap<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -798,7 +798,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 +859,23 @@ 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
|
||||
template <typename... T>
|
||||
flat_multiset(T...) -> flat_multiset<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_flat_multiset(T... t) -> etl::flat_multiset<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -883,7 +883,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 +944,23 @@ 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
|
||||
template <typename... T>
|
||||
flat_set(T...) -> flat_set<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_flat_set(T... t) -> etl::flat_set<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#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,22 @@ 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 +1837,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
|
||||
}
|
||||
|
||||
// Helper macros
|
||||
|
||||
@ -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,23 @@ 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 +2282,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.
|
||||
//*************************************************************************
|
||||
|
||||
@ -2214,7 +2214,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 +2279,25 @@ 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
|
||||
template <typename... T>
|
||||
map(T...) -> map<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_map(T... t) -> etl::map<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
|
||||
@ -530,7 +530,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_STL
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
//********************************************
|
||||
// Initializer_list constructor.
|
||||
//********************************************
|
||||
|
||||
@ -2076,7 +2076,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.
|
||||
//*************************************************************************
|
||||
@ -2146,6 +2146,26 @@ namespace etl
|
||||
1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
multimap(T...) -> multimap<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_multimap(T... t) -> etl::multimap<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the first lookup.
|
||||
|
||||
@ -2057,7 +2057,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 +2121,23 @@ 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
|
||||
template <typename... T>
|
||||
multiset(T...) -> multiset<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_multiset(T... t) -> etl::multiset<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
|
||||
@ -211,6 +211,12 @@ SOFTWARE.
|
||||
#define ETL_CONSTINIT
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_USING_STL && ETL_NOT_USING_STLPORT
|
||||
#define ETL_USING_INITIALIZER_LIST 1
|
||||
#else
|
||||
#define ETL_USING_INITIALIZER_LIST 0
|
||||
#endif
|
||||
|
||||
// Check for availability of certain builtins
|
||||
#include "profiles/determine_builtin_support.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.
|
||||
//***************************************************************************
|
||||
|
||||
@ -962,6 +962,28 @@ namespace etl
|
||||
etl::vector<node_t*, MAX_SIZE> lookup;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
reference_flat_map(T...) -> reference_flat_map<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_reference_flat_map(T... t) -> etl::reference_flat_map<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -858,6 +858,29 @@ namespace etl
|
||||
// The vector that stores pointers to the nodes.
|
||||
etl::vector<node_t*, MAX_SIZE> lookup;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
reference_flat_multimap(T...)->reference_flat_multimap<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_reference_flat_multimap(T... t) -> etl::reference_flat_multimap<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -840,6 +840,27 @@ namespace etl
|
||||
etl::vector<value_type*, MAX_SIZE> lookup;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
reference_flat_multiset(T...) -> reference_flat_multiset<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_reference_flat_multiset(T... t) -> etl::reference_flat_multiset<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the first reference_flat_multiset.
|
||||
|
||||
@ -824,6 +824,27 @@ namespace etl
|
||||
etl::vector<value_type*, MAX_SIZE> lookup;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename... T>
|
||||
reference_flat_set(T...) -> reference_flat_set<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_reference_flat_set(T... t) -> etl::reference_flat_set<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the first reference_flat_set.
|
||||
|
||||
@ -2140,7 +2140,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 +2203,23 @@ 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
|
||||
template <typename... T>
|
||||
set(T...) -> set<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_set(T... t) -> etl::set<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#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,33 @@ 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
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
// 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;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
@ -2014,6 +2014,93 @@ namespace etl
|
||||
template <typename T>
|
||||
inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable<T>::value;
|
||||
|
||||
#endif
|
||||
|
||||
//*********************************************
|
||||
// common_type
|
||||
// Based on the 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.
|
||||
//*************************************************************************
|
||||
|
||||
@ -1569,7 +1569,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 +1631,24 @@ 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
|
||||
template <typename... T>
|
||||
unordered_map(T...) -> unordered_map<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_unordered_map(T... t) -> etl::unordered_map<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1480,7 +1480,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 +1542,24 @@ 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
|
||||
template <typename... T>
|
||||
unordered_multimap(T...) ->unordered_multimap<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_unordered_multimap(T... t) -> etl::unordered_multimap<typename etl::common_type_t<typename T::first_type...>,
|
||||
typename etl::common_type_t<typename T::second_type...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1466,7 +1466,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 +1528,22 @@ 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
|
||||
template <typename... T>
|
||||
unordered_multiset(T...) -> unordered_multiset<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_unordered_multiset(T... t) -> etl::unordered_multiset<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1464,7 +1464,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 +1526,22 @@ 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
|
||||
template <typename... T>
|
||||
unordered_set(T...) -> unordered_set<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Make
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
template <typename... T>
|
||||
constexpr auto make_unordered_set(T... t) -> etl::unordered_set<typename etl::common_type_t<T...>,
|
||||
sizeof...(T)>
|
||||
{
|
||||
return { { etl::forward<T>(t)... } };
|
||||
}
|
||||
#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.
|
||||
//*************************************************************************
|
||||
|
||||
@ -33,6 +33,7 @@ SOFTWARE.
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
#include "etl/integral_limits.h"
|
||||
|
||||
@ -646,12 +647,47 @@ 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_USING_INITIALIZER_LIST
|
||||
TEST(test_make_array)
|
||||
{
|
||||
auto data = etl::make_array(char(0), short(1), int(2), long(3), 4, 5, 6, 7, 8, 9);
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
@ -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,49 @@ 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(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
|
||||
};
|
||||
}
|
||||
|
||||
@ -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(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(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,65 @@ 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)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const int, NDC>;
|
||||
|
||||
auto data = etl::make_flat_multiset(NDC("A"), NDC("B"), NDC("B2"), NDC("C"), NDC("D"), NDC("E"), NDC("F"));
|
||||
|
||||
auto 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,61 @@ 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)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const int, NDC>;
|
||||
|
||||
auto data = etl::make_flat_set(NDC("A"), NDC("B"), NDC("C"), NDC("D"), NDC("E"), NDC("F"));
|
||||
|
||||
auto 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_flat_map)
|
||||
{
|
||||
auto data = etl::make_forward_list(ItemNDC("A"), ItemNDC("B"), ItemNDC("C"), ItemNDC("D"), ItemNDC("E"), ItemNDC("F"));
|
||||
|
||||
auto v = *data.begin();
|
||||
using Type = decltype(v);
|
||||
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_flat_map)
|
||||
{
|
||||
auto data = etl::make_list(ItemNDC("A"), ItemNDC("B"), ItemNDC("C"), ItemNDC("D"), ItemNDC("E"), ItemNDC("F"));
|
||||
|
||||
auto v = *data.begin();
|
||||
using Type = decltype(v);
|
||||
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(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_map)
|
||||
{
|
||||
using Pair = ETL_OR_STD::pair<const std::string, int>;
|
||||
|
||||
auto data = etl::make_multimap(Pair("0", 0), Pair("1", 1), Pair("2", 2), Pair("3", 3), Pair("4", 4), Pair("5", 5));
|
||||
|
||||
auto 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_set_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_flat_set)
|
||||
{
|
||||
auto data = etl::make_multiset(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_flat_set)
|
||||
{
|
||||
auto data = etl::make_set(std::string("A"), std::string("B"), std::string("C"), std::string("D"), std::string("E"), std::string("F"));
|
||||
|
||||
auto 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), 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
|
||||
};
|
||||
}
|
||||
|
||||
@ -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,29 @@ namespace
|
||||
CHECK(i1 == *i2);
|
||||
CHECK(&i1 == i2);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_make_vector)
|
||||
{
|
||||
const long values[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
auto data = etl::make_vector( &values[0], &values[1], &values[2], &values[3], &values[4], &values[5], &values[6], &values[7], &values[8], &values[9] );
|
||||
|
||||
using Type = std::remove_reference_t<decltype(data[0])>;
|
||||
CHECK((std::is_same_v<const long*, Type>));
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user