mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-21 11:26:04 +08:00
Merge branch 'hotfix/remove-template-overload-abiguity' into development
# Conflicts: # include/etl/forward_list.h # include/etl/list.h # include/etl/vector.h # test/test_forward_list.cpp # test/test_list.cpp
This commit is contained in:
commit
11fa2e4e38
@ -241,18 +241,6 @@ namespace etl
|
||||
typedef const T* const_pointer;
|
||||
typedef typename etl::iterator_traits<pointer>::difference_type difference_type;
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
/// Test for an iterator.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
struct is_iterator : public etl::integral_constant<bool, !etl::is_integral<TIterator>::value && !etl::is_floating_point<TIterator>::value>
|
||||
{
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//*************************************************************************
|
||||
/// Iterator
|
||||
//*************************************************************************
|
||||
@ -730,7 +718,7 @@ namespace etl
|
||||
/// Assigns a range to the deque.
|
||||
//*************************************************************************
|
||||
template<typename TIterator>
|
||||
typename etl::enable_if<is_iterator<TIterator>::value, void>::type
|
||||
typename etl::enable_if<!etl::is_integral<TIterator>::value, void>::type
|
||||
assign(TIterator range_begin, TIterator range_end)
|
||||
{
|
||||
initialise();
|
||||
@ -1504,7 +1492,7 @@ namespace etl
|
||||
///\param range_end The end of the range to insert.
|
||||
//*************************************************************************
|
||||
template<typename TIterator>
|
||||
typename enable_if<is_iterator<TIterator>::value, iterator>::type
|
||||
typename enable_if<!etl::is_integral<TIterator>::value, iterator>::type
|
||||
insert(const_iterator insert_position, TIterator range_begin, TIterator range_end)
|
||||
{
|
||||
iterator position;
|
||||
|
||||
@ -647,7 +647,7 @@ namespace etl
|
||||
/// If ETL_THROW_EXCEPTIONS & ETL_DEBUG are defined throws forward_list_iterator if the iterators are reversed.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
void assign(TIterator first, TIterator last)
|
||||
void assign(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
|
||||
{
|
||||
#if defined(ETL_DEBUG)
|
||||
difference_type d = etl::distance(first, last);
|
||||
@ -977,7 +977,7 @@ namespace etl
|
||||
/// Inserts a range of values to the forward_list after the specified position.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
void insert_after(const_iterator position, TIterator first, TIterator last)
|
||||
void insert_after(iterator position, TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
|
||||
{
|
||||
#if defined(ETL_DEBUG)
|
||||
difference_type d = etl::distance(first, last);
|
||||
|
||||
@ -797,7 +797,7 @@ namespace etl
|
||||
/// If ETL_THROW_EXCEPTIONS & ETL_DEBUG are defined throws list_iterator if the iterators are reversed.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
void assign(TIterator first, TIterator last)
|
||||
void assign(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
|
||||
{
|
||||
#if defined(ETL_DEBUG)
|
||||
difference_type d = etl::distance(first, last);
|
||||
@ -822,7 +822,7 @@ namespace etl
|
||||
void assign(size_t n, const T& value)
|
||||
{
|
||||
#if defined(ETL_DEBUG)
|
||||
ETL_ASSERT(n <= available(), ETL_ERROR(list_full));
|
||||
ETL_ASSERT(n <= MAX_SIZE, ETL_ERROR(list_full));
|
||||
#endif
|
||||
|
||||
initialise();
|
||||
@ -1191,7 +1191,7 @@ namespace etl
|
||||
/// Inserts a range of values to the list at the specified position.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
void insert(const_iterator position, TIterator first, TIterator last)
|
||||
void insert(iterator position, TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
|
||||
{
|
||||
while (first != last)
|
||||
{
|
||||
|
||||
@ -382,7 +382,7 @@ namespace etl
|
||||
///\param first The iterator to the first element.
|
||||
///\param last The iterator to the last element + 1.
|
||||
//*********************************************************************
|
||||
template <typename TIterator>
|
||||
template <typename TIterator, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0>
|
||||
void assign(TIterator first, TIterator last)
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::iterator_traits<TIterator>::value_type>::type>::value), "Iterator type does not match container type");
|
||||
@ -802,7 +802,7 @@ namespace etl
|
||||
///\param last The last + 1 element to add.
|
||||
//*********************************************************************
|
||||
template <class TIterator>
|
||||
void insert(const_iterator position, TIterator first, TIterator last)
|
||||
void insert(iterator position, TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
|
||||
{
|
||||
size_t count = etl::distance(first, last);
|
||||
|
||||
|
||||
@ -1350,6 +1350,18 @@ namespace
|
||||
CHECK(data3 > data1);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_two_parameter_same_type_non_iterator)
|
||||
{
|
||||
// No compile error.
|
||||
etl::forward_list<int, 10> fl(10, 1);
|
||||
CHECK(fl.size() == 10);
|
||||
fl.assign(5, 2);
|
||||
CHECK(fl.size() == 5);
|
||||
fl.insert_after(fl.before_begin(), 5, 3);
|
||||
CHECK(fl.size() == fl.max_size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_forward_list_template_deduction)
|
||||
|
||||
@ -2028,6 +2028,17 @@ namespace
|
||||
CHECK_EQUAL(4U, (*itr++).value); // 4
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_same_type_non_iterator)
|
||||
{
|
||||
etl::list<int, 10> l(10, 1);
|
||||
CHECK(l.size() == 10);
|
||||
l.assign(5, 2);
|
||||
CHECK(l.size() == 5);
|
||||
l.insert(l.begin(), 5, 3);
|
||||
CHECK(l.size() == l.max_size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_USING_INITIALIZER_LIST
|
||||
TEST(test_forward_list_template_deduction)
|
||||
|
||||
@ -590,9 +590,9 @@ namespace
|
||||
DataNDC data1(pool);
|
||||
DataNDC data2(pool);
|
||||
|
||||
data1.assign(SIZE / 2UL, VALUE);
|
||||
data1.assign(SIZE, VALUE);
|
||||
|
||||
CHECK_THROW(data2.assign((SIZE / 2) + 1, VALUE), etl::list_full);
|
||||
CHECK_THROW(data2.assign(SIZE + 1, VALUE), etl::list_full);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -1276,6 +1276,22 @@ namespace
|
||||
etl::vector<int, 10> v(5, 5);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_two_parameter_assign_same_type_not_iterator)
|
||||
{
|
||||
// No compilation error.
|
||||
etl::vector<int, 10> v;
|
||||
v.assign(5, 5);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_three_parameter_insert_same_type_not_iterator)
|
||||
{
|
||||
// No compilation error.
|
||||
etl::vector<int, 10> v;
|
||||
v.insert(v.end(), 5, 5);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(remove)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user