Namespaces
Variants

std::indirect<T, Allocator>:: indirect

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
constexpr explicit indirect ( ) ;
(1) (C++26부터)
constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a ) ;
(2) (C++26부터)
template < class U = T >
constexpr explicit indirect ( U && v ) ;
(3) (C++26부터)
template < class U = T >

constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a,

U && v ) ;
(4) (C++26부터)
template < class ... Args >
constexpr explicit indirect ( std:: in_place_t , Args && ... args ) ;
(5) (C++26 이후)
template < class ... Args >

constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a,

std:: in_place_t , Args && ... args ) ;
(6) (C++26부터)
template < class I, class ... Args >

constexpr explicit indirect ( std:: in_place_t , std:: initializer_list < I > ilist,

Args && ... args ) ;
(7) (C++26부터)
template < class I, class ... Args >

constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a,
std:: in_place_t , std:: initializer_list < I > ilist,

Args && ... args ) ;
(8) (C++26부터)
constexpr indirect ( const indirect & other ) ;
(9) (C++26부터)
constexpr indirect ( std:: allocator_arg_t , const Allocator & a,
const indirect & other ) ;
(10) (C++26부터)
constexpr indirect ( indirect && other ) noexcept ;
(11) (C++26부터)
constexpr indirect ( std:: allocator_arg_t , const Allocator & a,
indirect && other ) noexcept ( /* 아래 참조 */ ) ;
(12) (C++26부터)

새로운 indirect 객체를 생성합니다.

목차

매개변수

a - 연결될 할당자
v - 소유한 값을 초기화할 값
args - 소유한 값을 초기화할 인수들
il - 소유한 값을 초기화할 초기화자 리스트
other - 소유한 값(존재하는 경우)이 복사될 다른 indirect 객체

효과

새로운 indirect 객체의 생성은 다음 단계들로 구성됩니다:

1) 관련된 할당자 alloc 를 생성합니다:
2) 소유된 객체를 생성합니다:
  • 오버로드 ( 1-8 ) 의 경우, p std:: allocator_traits < Allocator > :: allocate 호출 결과로 초기화한 다음, std:: allocator_traits < Allocator > :: construct ( alloc  , p  , args... ) 를 호출합니다. 여기서 args... 는 초기화 인수를 포함하는 표현식 팩입니다.
  • 오버로드 ( 9-12 ) 의 경우:
    • 만약 other 가 값이 없는 경우, 소유된 객체가 생성되지 않으며 생성 후 * this 도 값이 없게 됩니다.
    • 그렇지 않고, other 가 rvalue 참조이고 alloc other. alloc 와 같은 경우, * this other 의 소유된 객체의 소유권을 가져갑니다.
    • 그렇지 않으면, 소유된 객체는 위에서 설명한 대로 alloc 를 사용하여 생성됩니다.
오버로드 초기화 대상... valueless_after_move()
생성 후
alloc 소유된 객체
( 1 ) (비어 있음) (비어 있음) false
( 2 ) a
( 3 ) (비어 있음) std:: forward < U > ( v )
( 4 ) a
( 5 ) (비어 있음) std:: forward < Args > ( args )
( 6 ) a
( 7 ) (비어 있음) ilist, std:: forward < Args > ( args )
( 8 ) a
( 9 ) 아래 참조 * other
(only if other owns a value)
true only if other is valueless
( 10 ) a
( 11 ) std :: move ( other. alloc  ) 소유권 이전
(only if other owns a value)
( 12 ) a 아래 참조
9) alloc std:: allocator_traits < Allocator > ::
select_on_container_copy_construction ( other. alloc  )
로 직접-비목록-초기화됩니다.
12) 소유된 객체는 다음과 같이 구성됩니다:
  • 만약 other 가 값을 가지지 않으면, * this 도 값을 가지지 않습니다.
  • 그렇지 않고, alloc == other. alloc true 인 경우, * this other 의 소유된 객체에 대한 소유권을 가져옵니다.
  • 그렇지 않으면, alloc 를 사용하여 * std :: move ( other ) 로 소유된 객체를 구성합니다.

제약 조건 및 보충 정보

1,2) 만약 std:: is_default_constructible_v < T > false 인 경우, 프로그램의 형식이 올바르지 않습니다.

1) 이 오버로드는 std:: is_default_constructible_v < Allocator > true 인 경우에만 오버로드 해결에 참여합니다.

3-8) 이 오버로드들은 다음 조건이 std:: is_constructible_v < T, /* argument types */ > 일 때만 오버로드 해결에 참여합니다: true , 여기서 /* argument types */ 는 다음과 같습니다:
3,4) U
5,6) Args...
7,8) std:: initializer_list < I > & , Args...

3,5,7) 이 오버로드들은 다음 조건이 std:: is_default_constructible_v < Allocator > 일 때만 오버로드 해결에 참여합니다. true .
3,4) 다음 값들이 모두 false 인 경우에만 이 오버로드들이 오버로드 해결에 참여합니다:

9,10) 만약 std:: is_copy_constructible_v < T > false 인 경우, 프로그램의 형식이 올바르지 않습니다.
11,12) 생성이 완료되면, other 는 값을 가지지 않게 됩니다.
12) 만약 std:: allocator_traits < Allocator > :: is_always_equal :: value false 이고 T 불완전 타입 인 경우, 프로그램은 형식이 잘못되었습니다.

예외

std:: allocator_traits < Allocator > :: allocate 또는 std:: allocator_traits < Allocator > :: construct 가 예외를 던지지 않는 한 아무것도 던지지 않습니다.

12)
noexcept 명세:
noexcept ( std:: allocator_traits < Allocator > :: is_always_equal :: value )

예제

참고 항목

할당자 인식 생성자 오버로드를 선택하는 데 사용되는 태그 타입
(클래스)
인플레이스 생성 태그
(태그)