std::hive<T,Allocator>::insert_range
template< /*container-compatible-range*/<T> R > void insert_range( R&& rg ); | (since C++26) |
Inserts copies of elements in rg into hive at unspecified location and in unspecified order.
Each iterator in the range rg is dereferenced exactly once. Exactly one object of type T is constructed for each inserted element.
If rg and *this overlap, the behavior is undefined.
If an element is inserted, the end() iterator is invalidated.
Parameters
| rg | - | a container compatible range, that is, an input_range whose elements are convertible to T |
| Type requirements | ||
-T must be EmplaceConstructible into hive from *ranges::begin(rg). Otherwise, the behavior is undefined. |
||
Complexity
Linear in the number of inserted elements.
Example
#include <hive>
#include <print>
#include <vector>
int main()
{
auto hive = std::hive{1, 2, 3, 4};
const auto rg = std::vector{-1, -2, -3};
hive.erase(hive.begin());
std::println("{}", hive);
hive.insert_range(rg);
std::println("{}", hive);
}
Possible output:
[2, 3, 4] [-1, 2, 3, 4, -2, -3]
See also
| inserts elements (public member function) |
|
| constructs element in-place (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/container/hive/insert_range