Spec-Zone.ru › C++

std::hive<T,Allocator>::assign_range

template< /*container-compatible-range*/<T> R >
void assign_range( R&& rg );
(since C++26)

Replaces elements in the container with a copy of each element in rg.

All iterators and all references to the elements are invalidated.

Each iterator in the range rg is dereferenced exactly once.

The behavior is undefined if rg overlaps with the container.

Parameters

rg - an input_range with reference type convertible to the element type of the container
Type requirements
-std::assignable_from<T&, ranges::range_reference_t<R>> must be modeled. Otherwise, the program is ill-formed.
-T must be EmplaceConstructible into the container from *ranges::begin(rg). Otherwise, the behavior is undefined.

Example

#include <algorithm>
#include <cassert>
#include <hive>
#include <list>

int main()
{
    const auto source = std::list{2, 7, 1};
    auto destination = std::hive{3, 1, 4};
    destination.assign_range(source);
    assert(std::ranges::equal(source, destination));
}

See also

insert_range
inserts a range of elements
(public member function)
assign
assigns values to the container
(public member function)
operator=
assigns values to the container
(public member function)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/container/hive/assign_range

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API