std::inplace_vector<T,N>::assign_range
cppreference.net에서
template< /*container-compatible-range*/<T> R >
constexpr void assign_range( R&& rg );
|
(C++26부터) | |
컨테이너의 요소를 rg에 있는 각 요소의 복사본으로 대체합니다.
| 이 섹션은 불완전합니다 |
범위 rg의 각 반복자는 정확히 한 번 역참조됩니다.
동작은 rg이 컨테이너와 겹치는 경우 정의되지 않습니다.
매개변수
| rg | - |
컨테이너의 요소 타입으로 변환 가능한 참조 타입을 가진
input_range
|
| 타입 요구사항 | ||
|
-
|
||
-
T
가
*
ranges::
begin
(
rg
)
에서
inplace_vector
로
EmplaceConstructible
가 아니면, 동작은 정의되지 않습니다.
|
||
예외
- std::bad_alloc , 만약 std :: ranges:: distance ( rg ) > capacity ( ) .
- 삽입된 요소의 초기화 과정에서 발생하는 모든 예외.
예제
이 코드 실행
#include <algorithm> #include <cassert> #include <initializer_list> #include <inplace_vector> #include <iostream> #include <new> int main() { const auto source = {1, 2, 3}; std::inplace_vector<int, 4> destination{4, 5}; destination.assign_range(source); assert(std::ranges::equal(destination, source)); try { const auto bad = {-1, -2, -3, -4, -5}; destination.assign_range(bad); // throws: bad.size() > destination.capacity() } catch(const std::bad_alloc& ex) { std::cout << ex.what() << '\n'; } }
가능한 출력:
std::bad_alloc
참고 항목
|
요소 범위를 삽입합니다
(public member function) |
|
|
끝에 요소 범위를 추가합니다
(public member function) |
|
|
컨테이너에 값을 할당합니다
(public member function) |
|
|
컨테이너에 값을 할당합니다
(public member function) |