mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Added template deduction guides
This commit is contained in:
parent
e0d18c7141
commit
509089c0e2
@ -558,7 +558,7 @@ namespace etl
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename T, typename... Ts>
|
||||
array(T, Ts...)
|
||||
-> array<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1 + sizeof...(Ts)>;
|
||||
-> array<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -102,19 +102,19 @@ namespace etl
|
||||
typedef typename char_traits_types<T>::state_type state_type;
|
||||
|
||||
//*************************************************************************
|
||||
static bool eq(char_type a, char_type b)
|
||||
ETL_CONSTEXPR static bool eq(char_type a, char_type b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
static bool lt(char_type a, char_type b)
|
||||
ETL_CONSTEXPR static bool lt(char_type a, char_type b)
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
static size_t length(const char_type* str)
|
||||
ETL_CONSTEXPR14 static size_t length(const char_type* str)
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
|
||||
@ -186,6 +186,15 @@ namespace etl
|
||||
return CAPACITY;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the maximum possible size of the deque.
|
||||
///\return The maximum size of the deque.
|
||||
//*************************************************************************
|
||||
size_type capacity() const
|
||||
{
|
||||
return CAPACITY;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the remaining capacity.
|
||||
///\return The remaining capacity.
|
||||
@ -2457,6 +2466,15 @@ namespace etl
|
||||
typename etl::aligned_storage<sizeof(T), etl::alignment_of<T>::value>::type buffer[BUFFER_SIZE];
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)>;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the _begin deque.
|
||||
|
||||
@ -1004,6 +1004,17 @@ 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_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
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
@ -907,6 +907,17 @@ 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_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
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
@ -857,6 +857,15 @@ 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_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
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
@ -944,6 +944,15 @@ 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_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
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
@ -180,6 +180,14 @@ namespace etl
|
||||
return MAX_SIZE;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the maximum possible size of the forward_list.
|
||||
//*************************************************************************
|
||||
size_type capacity() const
|
||||
{
|
||||
return MAX_SIZE;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the size of the forward_list.
|
||||
//*************************************************************************
|
||||
@ -1726,6 +1734,15 @@ namespace etl
|
||||
etl::pool<typename etl::iforward_list<T>::data_node_t, MAX_SIZE> node_pool;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// A templated forward_list implementation that uses a fixed size pool.
|
||||
///\note 'merge' and 'splice_after' and are not supported.
|
||||
|
||||
@ -1404,6 +1404,15 @@ namespace etl
|
||||
etl::pool<T, MAX_SIZE> storage_pool;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
indirect_vector(T, Ts...)
|
||||
->indirect_vector<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// A indirect_vector implementation that uses a fixed size buffer.
|
||||
/// The buffer is supplied on construction.
|
||||
|
||||
@ -233,6 +233,14 @@ namespace etl
|
||||
return MAX_SIZE;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the maximum possible size of the list.
|
||||
//*************************************************************************
|
||||
size_type capacity() const
|
||||
{
|
||||
return MAX_SIZE;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the size of the list.
|
||||
//*************************************************************************
|
||||
@ -2158,6 +2166,15 @@ namespace etl
|
||||
etl::pool<typename etl::ilist<T>::data_node_t, MAX_SIZE> node_pool;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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
|
||||
|
||||
//*************************************************************************
|
||||
/// A templated list implementation that uses a fixed size buffer.
|
||||
//*************************************************************************
|
||||
|
||||
@ -2298,6 +2298,17 @@ namespace etl
|
||||
etl::pool<typename etl::imap<TKey, TValue, TCompare>::Data_Node, MAX_SIZE> node_pool;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the first lookup.
|
||||
|
||||
@ -2033,7 +2033,6 @@ namespace etl
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
@ -2158,6 +2157,17 @@ namespace etl
|
||||
etl::pool<typename etl::imultimap<TKey, TValue, TCompare>::Data_Node, MAX_SIZE> node_pool;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the first lookup.
|
||||
|
||||
@ -2140,6 +2140,15 @@ namespace etl
|
||||
etl::pool<typename etl::imultiset<TKey, TCompare>::Data_Node, MAX_SIZE> node_pool;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the first lookup.
|
||||
|
||||
@ -507,6 +507,14 @@ namespace etl
|
||||
bool valid;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template<class T>
|
||||
optional(T) -> optional<T>;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equality operator. cppreference 1
|
||||
//***************************************************************************
|
||||
|
||||
@ -256,7 +256,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
void release(const void* const p_object)
|
||||
{
|
||||
release_item((char*)p_object);
|
||||
const uintptr_t p = uintptr_t(p_object);
|
||||
release_item((char*)p);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -264,7 +265,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
void release_all()
|
||||
{
|
||||
items_allocated = 0;
|
||||
items_allocated = 0;
|
||||
items_initialised = 0;
|
||||
p_next = p_buffer;
|
||||
}
|
||||
@ -274,10 +275,10 @@ namespace etl
|
||||
/// \param p_object A pointer to the object to be checked.
|
||||
/// \return <b>true<\b> if it does, otherwise <b>false</b>
|
||||
//*************************************************************************
|
||||
//template <typename T>
|
||||
bool is_in_pool(const void* p_object) const
|
||||
{
|
||||
return is_item_in_pool((const char*)p_object);
|
||||
const uintptr_t p = uintptr_t(p_object);
|
||||
return is_item_in_pool((const char*)p);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -2221,6 +2221,15 @@ namespace etl
|
||||
etl::pool<typename etl::iset<TKey, TCompare>::Data_Node, MAX_SIZE> node_pool;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the first lookup.
|
||||
|
||||
@ -309,6 +309,24 @@ namespace etl
|
||||
element_type* mend;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename TArray>
|
||||
span(TArray& a)
|
||||
->span<typename TArray::value_type>;
|
||||
|
||||
template <typename TIterator>
|
||||
span(const TIterator begin_, const TIterator end_)
|
||||
->span<etl::remove_pointer_t<TIterator>>;
|
||||
|
||||
template <typename TIterator,
|
||||
typename TSize>
|
||||
span(const TIterator begin_, const TSize size_)
|
||||
->span<etl::remove_pointer_t<TIterator>>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Hash function.
|
||||
//*************************************************************************
|
||||
|
||||
@ -54,6 +54,10 @@ SOFTWARE.
|
||||
#include "debug_count.h"
|
||||
#include "iterator.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "16"
|
||||
|
||||
@ -1229,6 +1233,14 @@ namespace etl
|
||||
return pnodepool->max_size();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the maximum possible size of the unordered_map.
|
||||
//*************************************************************************
|
||||
size_type capacity() const
|
||||
{
|
||||
return pnodepool->max_size();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks to see if the unordered_map is empty.
|
||||
//*************************************************************************
|
||||
@ -1579,6 +1591,17 @@ namespace etl
|
||||
base::assign(first_, last_);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
unordered_map(std::initializer_list<ETL_OR_STD::pair<TKey, TValue>> init)
|
||||
: base(node_pool, buckets, MAX_BUCKETS_)
|
||||
{
|
||||
base::assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
@ -1626,6 +1649,17 @@ namespace etl
|
||||
/// The buckets of node lists.
|
||||
etl::intrusive_forward_list<typename base::node_t> buckets[MAX_BUCKETS_];
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)>;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
@ -54,6 +54,10 @@ SOFTWARE.
|
||||
#include "debug_count.h"
|
||||
#include "iterator.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "25"
|
||||
|
||||
@ -1135,6 +1139,14 @@ namespace etl
|
||||
return pnodepool->max_size();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the maximum possible size of the unordered_multimap.
|
||||
//*************************************************************************
|
||||
size_type capacity() const
|
||||
{
|
||||
return pnodepool->max_size();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks to see if the unordered_multimap is empty.
|
||||
//*************************************************************************
|
||||
@ -1491,6 +1503,17 @@ namespace etl
|
||||
base::assign(first_, last_);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
unordered_multimap(std::initializer_list<ETL_OR_STD::pair<TKey, TValue>> init)
|
||||
: base(node_pool, buckets, MAX_BUCKETS_)
|
||||
{
|
||||
base::assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
@ -1538,6 +1561,17 @@ namespace etl
|
||||
/// The buckets of node lists.
|
||||
etl::intrusive_forward_list<typename base::node_t> buckets[MAX_BUCKETS_];
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)>;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
@ -55,6 +55,10 @@ SOFTWARE.
|
||||
#include "debug_count.h"
|
||||
#include "iterator.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "26"
|
||||
|
||||
@ -1120,6 +1124,14 @@ namespace etl
|
||||
return pnodepool->max_size();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the maximum possible size of the unordered_multiset.
|
||||
//*************************************************************************
|
||||
size_type capacity() const
|
||||
{
|
||||
return pnodepool->max_size();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks to see if the unordered_multiset is empty.
|
||||
//*************************************************************************
|
||||
@ -1479,6 +1491,17 @@ namespace etl
|
||||
base::assign(first_, last_);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
unordered_multiset(std::initializer_list<TKey> init)
|
||||
: base(node_pool, buckets, MAX_BUCKETS)
|
||||
{
|
||||
base::assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
@ -1526,6 +1549,15 @@ namespace etl
|
||||
/// The buckets of node lists.
|
||||
etl::intrusive_forward_list<typename base::node_t> buckets[MAX_BUCKETS_];
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)>;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
@ -54,6 +54,10 @@ SOFTWARE.
|
||||
#include "debug_count.h"
|
||||
#include "iterator.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "23"
|
||||
|
||||
@ -1112,6 +1116,14 @@ namespace etl
|
||||
return pnodepool->max_size();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets the maximum possible size of the unordered_set.
|
||||
//*************************************************************************
|
||||
size_type capacity() const
|
||||
{
|
||||
return pnodepool->max_size();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Checks to see if the unordered_set is empty.
|
||||
//*************************************************************************
|
||||
@ -1475,6 +1487,17 @@ namespace etl
|
||||
base::assign(first_, last_);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
unordered_set(std::initializer_list<TKey> init)
|
||||
: base(node_pool, buckets, MAX_BUCKETS)
|
||||
{
|
||||
base::assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
@ -1522,6 +1545,15 @@ namespace etl
|
||||
/// The buckets of node lists.
|
||||
etl::intrusive_forward_list<typename base::node_t> buckets[MAX_BUCKETS_];
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)>;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
@ -230,6 +230,14 @@ namespace etl
|
||||
#endif
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename T1, typename T2>
|
||||
pair(T1, T2) ->pair<T1, T2>;
|
||||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <typename T1, typename T2>
|
||||
|
||||
@ -1286,6 +1286,15 @@ namespace etl
|
||||
typename etl::aligned_storage<sizeof(T) * MAX_SIZE, etl::alignment_of<T>::value>::type buffer;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)>;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// A vector implementation that uses a fixed size buffer.
|
||||
/// The buffer is supplied on construction.
|
||||
@ -1569,6 +1578,15 @@ namespace etl
|
||||
typename etl::aligned_storage<sizeof(T*) * MAX_SIZE, etl::alignment_of<T*>::value>::type buffer;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)>;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// A vector implementation that uses a fixed size buffer.
|
||||
/// The buffer is supplied on construction.
|
||||
|
||||
@ -38,8 +38,8 @@ SOFTWARE.
|
||||
///\ingroup utilities
|
||||
|
||||
#define ETL_VERSION_MAJOR 18
|
||||
#define ETL_VERSION_MINOR 15
|
||||
#define ETL_VERSION_PATCH 5
|
||||
#define ETL_VERSION_MINOR 16
|
||||
#define ETL_VERSION_PATCH 0
|
||||
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library",
|
||||
"version": "18.15.5",
|
||||
"version": "18.16.0",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "john.wellbelove@etlcpp.com"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library
|
||||
version=18.15.5
|
||||
version=18.16.0
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
===============================================================================
|
||||
18.16.0
|
||||
Added template deduction guides for most containers.
|
||||
|
||||
===============================================================================
|
||||
18.15.5
|
||||
Refactored empty(), full(), available() member functions for etl::list and etl::forward_list
|
||||
|
||||
@ -285,7 +285,7 @@ namespace
|
||||
|
||||
//*************************************************************************
|
||||
#ifndef ETL_COMPILER_MICROSOFT // Temporarily disabled as Appveyor reports an "internal compiler error
|
||||
TEST(test_cpp17_dedused_constructor)
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::array data{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
|
||||
@ -101,6 +101,24 @@ namespace
|
||||
CHECK_EQUAL(SIZE, data.max_size());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::deque data{ N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13 };
|
||||
etl::deque<NDC, 14> check = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13 };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(14U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(14U, data.capacity());
|
||||
CHECK_EQUAL(14U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_fill)
|
||||
{
|
||||
|
||||
@ -316,6 +316,26 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::flat_map data{ ElementNDC(0, N0), ElementNDC(1, N1), ElementNDC(2, N2), ElementNDC(3, N3), ElementNDC(4, N4),
|
||||
ElementNDC(5, N5), ElementNDC(6, N6), ElementNDC(7, N7), ElementNDC(8, N8), ElementNDC(9, N9) };
|
||||
etl::flat_map<int, NDC, 10U> check = { ElementNDC(0, N0), ElementNDC(1, N1), ElementNDC(2, N2), ElementNDC(3, N3), ElementNDC(4, N4),
|
||||
ElementNDC(5, N5), ElementNDC(6, N6), ElementNDC(7, N7), ElementNDC(8, N8), ElementNDC(9, N9) };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_destruct_via_iflat_map)
|
||||
{
|
||||
|
||||
@ -293,6 +293,26 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::flat_multimap data{ ElementNDC(0, N0), ElementNDC(1, N1), ElementNDC(2, N2), ElementNDC(3, N3), ElementNDC(4, N4),
|
||||
ElementNDC(5, N5), ElementNDC(6, N6), ElementNDC(7, N7), ElementNDC(8, N8), ElementNDC(9, N9) };
|
||||
etl::flat_multimap<int, NDC, 10U> check = { ElementNDC(0, N0), ElementNDC(1, N1), ElementNDC(2, N2), ElementNDC(3, N3), ElementNDC(4, N4),
|
||||
ElementNDC(5, N5), ElementNDC(6, N6), ElementNDC(7, N7), ElementNDC(8, N8), ElementNDC(9, N9) };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_destruct_via_iflat_multimap)
|
||||
{
|
||||
|
||||
@ -262,6 +262,24 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::flat_multiset data{ N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 };
|
||||
etl::flat_multiset<NDC, 10U> check = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_destruct_via_iflat_multiset)
|
||||
{
|
||||
|
||||
@ -274,6 +274,24 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::flat_set data{ N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 };
|
||||
etl::flat_set<NDC, 10U> check = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_destruct_via_iflat_set)
|
||||
{
|
||||
|
||||
@ -95,6 +95,24 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::forward_list data{ ItemNDC("1", 1), ItemNDC("2", 2), ItemNDC("3", 3), ItemNDC("2", 4), ItemNDC("0", 5), ItemNDC("2", 6), ItemNDC("7", 7), ItemNDC("4", 8), ItemNDC("4", 9), ItemNDC("8", 10) };
|
||||
etl::forward_list< ItemNDC, 10> check = { ItemNDC("1", 1), ItemNDC("2", 2), ItemNDC("3", 3), ItemNDC("2", 4), ItemNDC("0", 5), ItemNDC("2", 6), ItemNDC("7", 7), ItemNDC("4", 8), ItemNDC("4", 9), ItemNDC("8", 10) };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_size)
|
||||
{
|
||||
|
||||
@ -136,6 +136,24 @@ namespace
|
||||
CHECK_EQUAL(data.max_size(), SIZE);
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::indirect_vector data{ NDC("0"), NDC("1"), NDC("2"), NDC("3"), NDC("4"), NDC("5"), NDC("6"), NDC("7"), NDC("8"), NDC("9") };
|
||||
etl::indirect_vector<NDC, 10U> check = { NDC("0"), NDC("1"), NDC("2"), NDC("3"), NDC("4"), NDC("5"), NDC("6"), NDC("7"), NDC("8"), NDC("9") };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_destruct_via_ivector)
|
||||
{
|
||||
|
||||
@ -106,6 +106,24 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::list data{ ItemNDC("1", 1), ItemNDC("2", 2), ItemNDC("3", 3), ItemNDC("2", 4), ItemNDC("0", 5), ItemNDC("2", 6), ItemNDC("7", 7), ItemNDC("4", 8), ItemNDC("4", 9), ItemNDC("8", 10) };
|
||||
etl::list< ItemNDC, 10> check = { ItemNDC("1", 1), ItemNDC("2", 2), ItemNDC("3", 3), ItemNDC("2", 4), ItemNDC("0", 5), ItemNDC("2", 6), ItemNDC("7", 7), ItemNDC("4", 8), ItemNDC("4", 9), ItemNDC("8", 10) };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_destruct_via_ilist)
|
||||
{
|
||||
|
||||
@ -225,6 +225,26 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::map data{ std::pair<std::string, int>("0", 0), std::pair<std::string, int>("1", 1), std::pair<std::string, int>("2", 2), std::pair<std::string, int>("3", 3), std::pair<std::string, int>("4", 4),
|
||||
std::pair<std::string, int>("5", 5), std::pair<std::string, int>("6", 6), std::pair<std::string, int>("7", 7), std::pair<std::string, int>("8", 8), std::pair<std::string, int>("9", 9) };
|
||||
etl::map<std::string, int, 10U> check = { std::pair<std::string, int>("0", 0), std::pair<std::string, int>("1", 1), std::pair<std::string, int>("2", 2), std::pair<std::string, int>("3", 3), std::pair<std::string, int>("4", 4),
|
||||
std::pair<std::string, int>("5", 5), std::pair<std::string, int>("6", 6), std::pair<std::string, int>("7", 7), std::pair<std::string, int>("8", 8), std::pair<std::string, int>("9", 9) };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_copy_constructor)
|
||||
{
|
||||
|
||||
@ -227,6 +227,26 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::multimap data{ std::pair<std::string, int>("0", 0), std::pair<std::string, int>("1", 1), std::pair<std::string, int>("2", 2), std::pair<std::string, int>("3", 3), std::pair<std::string, int>("4", 4),
|
||||
std::pair<std::string, int>("5", 5), std::pair<std::string, int>("6", 6), std::pair<std::string, int>("7", 7), std::pair<std::string, int>("8", 8), std::pair<std::string, int>("9", 9) };
|
||||
etl::multimap<std::string, int, 10U> check = { std::pair<std::string, int>("0", 0), std::pair<std::string, int>("1", 1), std::pair<std::string, int>("2", 2), std::pair<std::string, int>("3", 3), std::pair<std::string, int>("4", 4),
|
||||
std::pair<std::string, int>("5", 5), std::pair<std::string, int>("6", 6), std::pair<std::string, int>("7", 7), std::pair<std::string, int>("8", 8), std::pair<std::string, int>("9", 9) };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_copy_constructor)
|
||||
{
|
||||
|
||||
@ -234,6 +234,24 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::multiset data{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::multiset<int, 10U> check = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_copy_constructor)
|
||||
{
|
||||
|
||||
@ -68,7 +68,6 @@ namespace
|
||||
CHECK(!data1.has_value());
|
||||
CHECK(!data2.has_value());
|
||||
|
||||
|
||||
data1 = Data("Hello");
|
||||
CHECK(bool(data1));
|
||||
CHECK(data1.has_value());
|
||||
@ -97,7 +96,18 @@ namespace
|
||||
data4 = etl::nullopt;
|
||||
CHECK(!bool(data4));
|
||||
CHECK(!data4.has_value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_deduced_initialisation)
|
||||
{
|
||||
Data data("Hello");
|
||||
|
||||
etl::optional opt{ data };
|
||||
|
||||
CHECK(opt.has_value());
|
||||
CHECK(bool(opt));
|
||||
CHECK_EQUAL(data, opt);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -244,11 +244,30 @@ namespace
|
||||
|
||||
CHECK_EQUAL(data.size(), size_t(0));
|
||||
CHECK(data.empty());
|
||||
CHECK_EQUAL(data.capacity(), MAX_SIZE);
|
||||
CHECK_EQUAL(data.max_size(), MAX_SIZE);
|
||||
CHECK_EQUAL(MAX_SIZE, data.available());
|
||||
CHECK_EQUAL(MAX_SIZE, data.capacity());
|
||||
CHECK_EQUAL(MAX_SIZE, data.max_size());
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::set data{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::set<int, 10U> check = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_copy_constructor)
|
||||
{
|
||||
|
||||
@ -247,6 +247,36 @@ namespace
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::array data{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
etl::span span1{ data };
|
||||
etl::span span2{ data.begin(), data.end() };
|
||||
etl::span span3{ data.begin(), data.size() };
|
||||
etl::span span4{ span1 };
|
||||
|
||||
int c_array[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::span span5{ c_array };
|
||||
|
||||
bool isEqual = false;
|
||||
|
||||
isEqual = std::equal(span1.begin(), span1.end(), data.begin());
|
||||
CHECK(isEqual);
|
||||
|
||||
isEqual = std::equal(span2.begin(), span2.end(), data.begin());
|
||||
CHECK(isEqual);
|
||||
|
||||
isEqual = std::equal(span3.begin(), span3.end(), data.begin());
|
||||
CHECK(isEqual);
|
||||
|
||||
isEqual = std::equal(span4.begin(), span4.end(), data.begin());
|
||||
CHECK(isEqual);
|
||||
|
||||
isEqual = std::equal(span5.begin(), span5.end(), c_array);
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_range)
|
||||
{
|
||||
|
||||
@ -43,6 +43,7 @@ SOFTWARE.
|
||||
#include "data.h"
|
||||
|
||||
#include "etl/unordered_map.h"
|
||||
#include "etl/hash.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -73,19 +74,35 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef TestDataDC<std::string> DC;
|
||||
typedef TestDataNDC<std::string> NDC;
|
||||
|
||||
typedef ETL_OR_STD::pair<std::string, DC> ElementDC;
|
||||
typedef ETL_OR_STD::pair<std::string, NDC> ElementNDC;
|
||||
}
|
||||
|
||||
namespace etl
|
||||
{
|
||||
template <>
|
||||
struct hash<std::string>
|
||||
{
|
||||
size_t operator ()(const std::string& e) const
|
||||
{
|
||||
size_t sum = 0U;
|
||||
return std::accumulate(e.begin(), e.end(), sum);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_unordered_map)
|
||||
{
|
||||
static const size_t SIZE = 10;
|
||||
|
||||
typedef TestDataDC<std::string> DC;
|
||||
typedef TestDataNDC<std::string> NDC;
|
||||
|
||||
using ItemM = TestDataM<int>;
|
||||
using DataM = etl::unordered_map<std::string, ItemM, SIZE, SIZE, std::hash<std::string>>;
|
||||
|
||||
typedef ETL_OR_STD::pair<std::string, DC> ElementDC;
|
||||
typedef ETL_OR_STD::pair<std::string, NDC> ElementNDC;
|
||||
|
||||
typedef etl::unordered_map<std::string, DC, SIZE, SIZE / 2, simple_hash> DataDC;
|
||||
typedef etl::unordered_map<std::string, NDC, SIZE, SIZE / 2, simple_hash> DataNDC;
|
||||
typedef etl::iunordered_map<std::string, NDC, simple_hash> IDataNDC;
|
||||
@ -227,6 +244,26 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::unordered_map data{ ElementNDC(K0, N0), ElementNDC(K1, N1), ElementNDC(K2, N2), ElementNDC(K3, N3), ElementNDC(K4, N4),
|
||||
ElementNDC(K5, N5), ElementNDC(K6, N6), ElementNDC(K7, N7), ElementNDC(K8, N8), ElementNDC(K9, N9) };
|
||||
etl::unordered_map<std::string, NDC, 10U, 10U> check = { ElementNDC(K0, N0), ElementNDC(K1, N1), ElementNDC(K2, N2), ElementNDC(K3, N3), ElementNDC(K4, N4),
|
||||
ElementNDC(K5, N5), ElementNDC(K6, N6), ElementNDC(K7, N7), ElementNDC(K8, N8), ElementNDC(K9, N9) };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_range)
|
||||
{
|
||||
|
||||
@ -42,6 +42,19 @@ SOFTWARE.
|
||||
|
||||
#include "etl/unordered_multimap.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
template <>
|
||||
struct hash<std::string>
|
||||
{
|
||||
size_t operator ()(const std::string& e) const
|
||||
{
|
||||
size_t sum = 0U;
|
||||
return std::accumulate(e.begin(), e.end(), sum);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
//*************************************************************************
|
||||
@ -71,6 +84,12 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef TestDataDC<std::string> DC;
|
||||
typedef TestDataNDC<std::string> NDC;
|
||||
|
||||
typedef ETL_OR_STD::pair<std::string, DC> ElementDC;
|
||||
typedef ETL_OR_STD::pair<std::string, NDC> ElementNDC;
|
||||
|
||||
SUITE(test_unordered_multimap)
|
||||
{
|
||||
static const size_t SIZE = 10;
|
||||
@ -202,6 +221,26 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::unordered_multimap data{ ElementNDC(K0, N0), ElementNDC(K1, N1), ElementNDC(K2, N2), ElementNDC(K3, N3), ElementNDC(K4, N4),
|
||||
ElementNDC(K5, N5), ElementNDC(K6, N6), ElementNDC(K7, N7), ElementNDC(K8, N8), ElementNDC(K9, N9) };
|
||||
etl::unordered_multimap<std::string, NDC, 10U, 10U> check = { ElementNDC(K0, N0), ElementNDC(K1, N1), ElementNDC(K2, N2), ElementNDC(K3, N3), ElementNDC(K4, N4),
|
||||
ElementNDC(K5, N5), ElementNDC(K6, N6), ElementNDC(K7, N7), ElementNDC(K8, N8), ElementNDC(K9, N9) };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_range)
|
||||
{
|
||||
|
||||
@ -42,15 +42,31 @@ SOFTWARE.
|
||||
#include "etl/unordered_multiset.h"
|
||||
#include "etl/checksum.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef TestDataDC<std::string> DC;
|
||||
typedef TestDataNDC<std::string> NDC;
|
||||
}
|
||||
|
||||
namespace etl
|
||||
{
|
||||
template <>
|
||||
struct hash<NDC>
|
||||
{
|
||||
size_t operator ()(const NDC& e) const
|
||||
{
|
||||
size_t sum = 0U;
|
||||
return std::accumulate(e.value.begin(), e.value.end(), sum);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_unordered_multiset)
|
||||
{
|
||||
static const size_t SIZE = 10;
|
||||
|
||||
typedef TestDataDC<std::string> DC;
|
||||
typedef TestDataNDC<std::string> NDC;
|
||||
|
||||
using ItemM = TestDataM<int>;
|
||||
|
||||
struct simple_hash
|
||||
@ -146,6 +162,24 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::unordered_multiset data{ N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 };
|
||||
etl::unordered_multiset<NDC, 10U> check = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_range)
|
||||
{
|
||||
|
||||
@ -40,6 +40,26 @@ SOFTWARE.
|
||||
|
||||
#include "etl/unordered_set.h"
|
||||
#include "etl/checksum.h"
|
||||
#include "etl/hash.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef TestDataDC<std::string> DC;
|
||||
typedef TestDataNDC<std::string> NDC;
|
||||
}
|
||||
|
||||
namespace etl
|
||||
{
|
||||
template <>
|
||||
struct hash<NDC>
|
||||
{
|
||||
size_t operator ()(const NDC& e) const
|
||||
{
|
||||
size_t sum = 0U;
|
||||
return std::accumulate(e.value.begin(), e.value.end(), sum);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -47,9 +67,6 @@ namespace
|
||||
{
|
||||
static const size_t SIZE = 10;
|
||||
|
||||
typedef TestDataDC<std::string> DC;
|
||||
typedef TestDataNDC<std::string> NDC;
|
||||
|
||||
using ItemM = TestDataM<int>;
|
||||
|
||||
struct simple_hash
|
||||
@ -138,6 +155,24 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::unordered_set data{ N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 };
|
||||
etl::unordered_set<NDC, 10U> check = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_constructor_range)
|
||||
{
|
||||
|
||||
@ -60,7 +60,7 @@ namespace
|
||||
{
|
||||
etl::pair<int, double> p1;
|
||||
|
||||
CHECK_EQUAL(int(), p1.first);
|
||||
CHECK_EQUAL(int(), p1.first);
|
||||
CHECK_EQUAL(double(), p1.second);
|
||||
}
|
||||
|
||||
@ -69,7 +69,19 @@ namespace
|
||||
{
|
||||
etl::pair<int, double> p1(1, 2.3);
|
||||
|
||||
CHECK_EQUAL(1, p1.first);
|
||||
CHECK_EQUAL(1, p1.first);
|
||||
CHECK_EQUAL(2.3, p1.second);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_pair_construct)
|
||||
{
|
||||
etl::pair p1{ 1, 2.3 };
|
||||
|
||||
CHECK((std::is_same_v<decltype(p1.first), int>));
|
||||
CHECK((std::is_same_v<decltype(p1.second), double>));
|
||||
|
||||
CHECK_EQUAL(1, p1.first);
|
||||
CHECK_EQUAL(2.3, p1.second);
|
||||
}
|
||||
|
||||
@ -78,7 +90,7 @@ namespace
|
||||
{
|
||||
etl::pair<ItemM1, ItemM2> p1(1, 2.3);
|
||||
|
||||
CHECK_EQUAL(1, p1.first.value);
|
||||
CHECK_EQUAL(1, p1.first.value);
|
||||
CHECK_EQUAL(2.3, p1.second.value);
|
||||
}
|
||||
|
||||
@ -88,7 +100,7 @@ namespace
|
||||
etl::pair<int, double> p1(1, 2.3);
|
||||
etl::pair<int, double> p2(p1);
|
||||
|
||||
CHECK_EQUAL(p1.first, p2.first);
|
||||
CHECK_EQUAL(p1.first, p2.first);
|
||||
CHECK_EQUAL(p1.second, p2.second);
|
||||
}
|
||||
|
||||
@ -101,7 +113,7 @@ namespace
|
||||
CHECK(!bool(p1.first));
|
||||
CHECK(!bool(p1.second));
|
||||
|
||||
CHECK_EQUAL(1, p2.first.value);
|
||||
CHECK_EQUAL(1, p2.first.value);
|
||||
CHECK_EQUAL(2.3, p2.second.value);
|
||||
}
|
||||
|
||||
@ -111,7 +123,7 @@ namespace
|
||||
etl::pair<char, float> p1(1, 2.3f);
|
||||
etl::pair<int, double> p2(p1);
|
||||
|
||||
CHECK_EQUAL(p1.first, p2.first);
|
||||
CHECK_EQUAL(p1.first, p2.first);
|
||||
CHECK_EQUAL(p1.second, p2.second);
|
||||
}
|
||||
|
||||
@ -122,7 +134,7 @@ namespace
|
||||
etl::pair<int, double> p2;
|
||||
p2 = etl::make_pair(1, 2.3);
|
||||
|
||||
CHECK_EQUAL(p1.first, p2.first);
|
||||
CHECK_EQUAL(p1.first, p2.first);
|
||||
CHECK_EQUAL(p1.second, p2.second);
|
||||
}
|
||||
|
||||
@ -146,10 +158,10 @@ namespace
|
||||
|
||||
p1.swap(p2);
|
||||
|
||||
CHECK_EQUAL(2, p1.first);
|
||||
CHECK_EQUAL(2, p1.first);
|
||||
CHECK_EQUAL(3.4, p1.second);
|
||||
|
||||
CHECK_EQUAL(1, p2.first);
|
||||
CHECK_EQUAL(1, p2.first);
|
||||
CHECK_EQUAL(2.3, p2.second);
|
||||
}
|
||||
|
||||
@ -161,10 +173,10 @@ namespace
|
||||
|
||||
swap(p1, p2);
|
||||
|
||||
CHECK_EQUAL(2, p1.first);
|
||||
CHECK_EQUAL(2, p1.first);
|
||||
CHECK_EQUAL(3.4, p1.second);
|
||||
|
||||
CHECK_EQUAL(1, p2.first);
|
||||
CHECK_EQUAL(1, p2.first);
|
||||
CHECK_EQUAL(2.3, p2.second);
|
||||
}
|
||||
|
||||
|
||||
@ -83,6 +83,24 @@ namespace
|
||||
CHECK(data.begin() == data.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::vector data{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
etl::vector<int, 10U> check = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_iterator_comparison_empty)
|
||||
{
|
||||
|
||||
@ -92,6 +92,24 @@ namespace
|
||||
CHECK_EQUAL(data.max_size(), SIZE);
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::vector data{ NDC("0"), NDC("1"), NDC("2"), NDC("3"), NDC("4"), NDC("5"), NDC("6"), NDC("7"), NDC("8"), NDC("9") };
|
||||
etl::vector<NDC, 10U> check = { NDC("0"), NDC("1"), NDC("2"), NDC("3"), NDC("4"), NDC("5"), NDC("6"), NDC("7"), NDC("8"), NDC("9") };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_destruct_via_ivector)
|
||||
{
|
||||
|
||||
@ -55,26 +55,25 @@ namespace
|
||||
Compare_Data different_data;
|
||||
Compare_Data insert_data;
|
||||
|
||||
int n0 = 0;
|
||||
int n1 = 1;
|
||||
int n2 = 2;
|
||||
int n3 = 3;
|
||||
int n4 = 4;
|
||||
int n5 = 5;
|
||||
int n6 = 6;
|
||||
int n7 = 7;
|
||||
int n8 = 8;
|
||||
int n9 = 9;
|
||||
int n11 = 11;
|
||||
int n12 = 12;
|
||||
int n13 = 13;
|
||||
|
||||
//*************************************************************************
|
||||
struct SetupFixture
|
||||
{
|
||||
SetupFixture()
|
||||
{
|
||||
int n0 = 0;
|
||||
int n1 = 1;
|
||||
int n2 = 2;
|
||||
int n3 = 3;
|
||||
int n4 = 4;
|
||||
int n5 = 5;
|
||||
int n6 = 6;
|
||||
int n7 = 7;
|
||||
int n8 = 8;
|
||||
int n9 = 9;
|
||||
int n11 = 11;
|
||||
int n12 = 12;
|
||||
int n13 = 13;
|
||||
|
||||
|
||||
int* n[] = { &n0, &n1, &n2, &n3, &n4, &n5, &n6, &n7, &n8, &n9 };
|
||||
int* n_insert[] = { &n11, &n12, &n13 };
|
||||
int* n_less[] = { &n0, &n1, &n2, &n3, &n3, &n5, &n6, &n7, &n8, &n9 };
|
||||
@ -100,6 +99,24 @@ namespace
|
||||
CHECK_EQUAL(data.max_size(), SIZE);
|
||||
}
|
||||
|
||||
#if ETL_USING_STL
|
||||
//*************************************************************************
|
||||
TEST(test_cpp17_deduced_constructor)
|
||||
{
|
||||
etl::vector data{ &n0, &n1, &n2, &n3, &n4, &n5, &n6, &n7, &n8, &n9 };
|
||||
etl::vector<int*, 10U> check = { &n0, &n1, &n2, &n3, &n4, &n5, &n6, &n7, &n8, &n9 };
|
||||
|
||||
CHECK(!data.empty());
|
||||
CHECK(data.full());
|
||||
CHECK(data.begin() != data.end());
|
||||
CHECK_EQUAL(0U, data.available());
|
||||
CHECK_EQUAL(10U, data.capacity());
|
||||
CHECK_EQUAL(10U, data.size());
|
||||
CHECK_EQUAL(10U, data.max_size());
|
||||
CHECK(data == check);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_const_default_constructor)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user