Avoid using inheriting constructors and initializer_list::cbegin/cend to be nicer with older compilers

This commit is contained in:
Ion Gaztañaga
2021-01-01 23:44:56 +01:00
parent 6c23ce8b42
commit 621cd3a0ab
2 changed files with 16 additions and 4 deletions

View File

@@ -351,9 +351,11 @@ class devector
const size_type n = boost::container::iterator_distance(first, last);
m_.buffer = n ? allocate(n) : pointer();
m_.front_idx = 0u;
//this->allocate(n) will take care of overflows
m_.set_back_idx(n);
m_.set_capacity(n);
construct_from_range(first, last);
//construct_from_range releases memory on failure
this->construct_from_range(first, last);
BOOST_ASSERT(invariants_ok());
}
@@ -464,8 +466,18 @@ class devector
* **Equivalent to**: `devector(il.begin(), il.end())` or `devector(il.begin(), il.end(), allocator)`.
*/
devector(const std::initializer_list<T>& il, const allocator_type& allocator = allocator_type())
: devector(il.begin(), il.end(), allocator)
{}
: m_(allocator, pointer(), 0u, 0u, 0u)
{
const size_type n = il.size();
m_.buffer = n ? allocate(n) : pointer();
m_.front_idx = 0u;
//this->allocate(n) will take care of overflows
m_.set_back_idx(n);
m_.set_capacity(n);
//construct_from_range releases memory on failure
this->construct_from_range(il.begin(), il.end());
BOOST_ASSERT(invariants_ok());
}
#endif
/**

View File

@@ -73,7 +73,7 @@ void print_range(std::ostream& out, Iterator b, Iterator e)
template <typename Range>
void print_range(std::ostream& out, const Range& range)
{
print_range(out, range.cbegin(), range.cend());
print_range(out, range.begin(), range.end());
}
template <typename Array, std::size_t N>