Commit b46cb754 authored by Quentin Khan's avatar Quentin Khan

Fix variadic_container initializer_list constructor

The intializer_list constructor of the container would forward the list
to the ranged insert method. By design, and for efficiency reasons, this
implementation of insert awaits tuples of iterators instead of iterator
to tuples. This would fail to compile.

The constructor now calls the insert overload for a value for each
element of the initializer_list.

Two static assertions are added to the ranged insert should the problem
arise again.
parent 07889707
......@@ -803,8 +803,11 @@ public:
* \param ilist Initializer_list to assign to the container
void assign(std::initializer_list<value_type> ilist) {
insert(begin(), ilist.begin(), ilist.end());
for(auto&& i : ilist) {
insert(end(), i);
/** \brief Deletes all elements from the vector */
......@@ -991,6 +994,14 @@ private:
return p - count;
template<class T>
struct is_tuple_get_like {
template<class U, class = decltype(std::get<0>(std::declval<U>()))>
static constexpr bool check(U*) {return true;}
static constexpr bool check(...) {return false;}
enum {value = check(static_cast<T*>(nullptr))};
/** \brief Insert elements from a range
......@@ -1008,6 +1019,11 @@ public:
template<class TupleIterator>
iterator insert(const_iterator pos, TupleIterator first, TupleIterator last) {
"TupleIterator is not convertible to a tuple of iterators");
static_assert(std::tuple_size<TupleIterator>::value == sizeof...(Types),
"TupleIterator has wrong size...");
size_type pos_idx = pos - this->begin();
size_type count = last - first;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment