memory_uninitialized_move
memory_uninitialized_move (std::uninitialized_move)
<memory> 헤더에 정의되어 있어요. 소스 범위 [first, last)의 요소를 대상 범위로 이동해 구성해요. C++17부터 도입됐어요.
출처: cppreference
본문
template< class InputIt, class NoThrowForwardIt >
NoThrowForwardIt uninitialized_move( InputIt first, InputIt last, NoThrowForwardIt d_first ); // (1) since C++17, constexpr since C++26
template< class ExecutionPolicy, class ForwardIt, class NoThrowForwardIt >
NoThrowForwardIt uninitialized_move( ExecutionPolicy&& policy, ForwardIt first, ForwardIt last, NoThrowForwardIt d_first ); // (2) since C++17
- (1) 소스 범위
[first, last)의 요소를d_first에서 시작하는 대상 범위로 이동해 구성해요. 각 대상 요소는std::move된 소스 요소로 구성돼요. 초기화 중 예외가 발생하면 이미 구성된 객체들이 미지정 순서로 파괴돼요. - (2) (1)과 같지만
policy에 따라 실행돼요.
매개변수
first, last: 이동할 요소 범위를 정의하는 반복자 쌍d_first: 대상 범위의 시작policy: 사용할 실행 정책
반환값
마지막으로 구성한 요소 다음의 반복자.
std::vector<T> src = ...;
T* buf = ...;
auto last = std::uninitialized_move(src.begin(), src.end(), buf);
무버를 이용해 초기화되지 않은 메모리에 객체를 이동 구성할 때 써요. std::move_iterator를 쓴 std::uninitialized_copy와 유사해요.