ranges_uninitialized_copy_n
ranges_uninitialized_copy_n (ranges::uninitialized_copy_n)
<memory> 헤더에 정의되어 있어요. 입력 범위의 처음 count개 요소를 초기화되지 않은 대상 저장 공간에 복사해 구성해요. std::uninitialized_copy_n의 ranges 버전(니블로이드, niebloid)이에요. C++20부터 도입됐어요.
출처: cppreference
본문
호출 시그니처:
template< std::input_iterator I,
/*nothrow-input-iterator*/ O, /*nothrow-sentinel-for*/<O> S >
requires std::constructible_from<std::iter_value_t<O>,
std::iter_reference_t<I>>
uninitialized_copy_n_result<I, O>
uninitialized_copy_n( I ifirst, std::iter_difference_t<I> count,
O ofirst, S olast ); // (1) since C++20, constexpr since C++26
template< /*execution-policy*/ Ep, std::random_access_iterator I,
/*nothrow-random-access-iterator*/ O,
/*nothrow-sentinel-for*/<O> S >
requires std::constructible_from<std::iter_value_t<O>,
std::iter_reference_t<I>>
uninitialized_copy_n_result<I, O>
uninitialized_copy_n( Ep&& policy, I ifirst, std::iter_difference_t<I> count,
O ofirst, S olast ); // (2) since C++26
소스 범위 [ifirst, ifirst + count)의 요소를 대상 범위 [ofirst, olast)에 초기화해 복사해요. 각 대상 요소는 std::construct_at(std::addressof(*o), std::iter_reference_t<I>(*i))로 구성돼요.
- (1) 직렬 버전.
- (2) 실행 정책
policy에 따라 병렬 실행될 수 있어요. (C++26)
객체가 소스에서 대상으로 이동되는 대신 복사되고, 대상 저장 공간은 초기화되지 않은 상태로 가정돼요. 예외가 발생하면 이미 구성된 요소들이 파괴돼요.
이 페이지에 설명된 함수 같은 개체들은 알고리즘 함수 객체(니블로이드)라서, 명시적 템플릿 인자 목록을 쓸 수 없고(함수 호출 시점에 추론), 인자 연관 탐색으로 찾을 수 있어요.
반환값
{last-copied-input, last-constructed-output} 형태의 uninitialized_copy_n_result를 돌려줘요.