std::inplace_vector<T,N>::append_range
From cppreference.com
 
 
 < cpp | container | inplace vector 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Containers library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
(C++17)
(C++11)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++23)
(C++23)
(C++20)
(C++23)
 Tables
std::inplace_vector 
 
 
 
inplace_vector::append_range
template< container-compatible-range <T> R >
constexpr void append_range( R&& rg );
 
 (since C++26)
constexpr void append_range( R&& rg );
Inserts copies of elements from the range rg before end(), in non-reversing order.
Each iterator in rg is dereferenced exactly once.
[edit] Parameters
 Type requirements
 -If 
T is not EmplaceConstructible into inplace_vector from *ranges::begin (rg), the behavior is undefined.
[edit] Complexity
Linear in size of rg. The number of calls to the constructor of T is exactly equal to the std::ranges::size (rg)).
[edit] Exceptions
Throws std::bad_alloc  if std::ranges::size (rg) > N.
If an exception is thrown other than by the copy constructor, move constructor, assignment operator, or move assignment operator of T or by any InputIterator operation, there are no effects.
Otherwise, if an exception is thrown, then size() >= n and elements in the range [0, n) are not modified,
where n is the value of size() before this call.
[edit] Example
Run this code
#include <cassert> #include <inplace_vector> #include <iostream> int main() { using I = std::inplace_vector <int, 8>; auto head = I{1, 2, 3, 4}; const auto tail = {-5, -6, -7}; head.append_range(tail); assert (head.size() == 7 and (head == I{1, 2, 3, 4, -5, -6, -7})); try { head.append_range(tail); // throws: no space } catch(const std::bad_alloc &) { std::cout << "std::bad_alloc\n"; } }
Output:
std::bad_alloc