Namespaces
Variants

std::polymorphic<T, Allocator>:: polymorphic

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 polymorphic ( ) ;
(1) (C++26부터)
constexpr explicit polymorphic ( std:: allocator_arg_t , const Allocator & a ) ;
(2) (C++26부터)
template < class U = T >
constexpr explicit polymorphic ( U && v ) ;
(3) (C++26부터)
template < class U = T >

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

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

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

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

constexpr explicit polymorphic ( std:: in_place_type_t < U > ,
std:: initializer_list < I > ilist,

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

constexpr explicit polymorphic ( std:: allocator_arg_t , const Allocator & a,
std:: in_place_type_t < U > ,
std:: initializer_list < I > ilist,

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

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

목차

매개변수

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

효과

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

1) 관련된 allocator alloc 를 생성합니다:
2) 소유 객체를 생성합니다:
  • 오버로드 ( 1-8 ) 의 경우, std:: allocator_traits < Allocator > :: construct ( alloc  , p, args... ) 를 호출합니다. 여기서
    • p U* 타입의 포인터로, 생성될 소유 객체를 위한 저장 공간을 가리키며,
    • args... 는 초기화 인수를 포함하는 표현식 팩입니다.
  • 오버로드 ( 9-12 ) 의 경우:
    • 만약 other 가 값이 없는 상태라면, 소유 객체가 생성되지 않으며 생성 후 * this 도 값이 없는 상태가 됩니다.
    • 그렇지 않고, other 가 rvalue 참조이며 alloc other. alloc 와 같다면, * this other 의 소유 객체에 대한 소유권을 가져갑니다.
    • 그렇지 않으면, 소유 객체는 위에서 설명한 대로 alloc 를 사용하여 생성되며, 여기서 p 의 타입은 other 가 소유한 객체의 타입에 의해 결정됩니다.
오버로드 초기화 대상... 소유 객체의 타입 valueless_after_move()
생성 후
alloc 소유 객체
( 1 ) (비어 있음) (비어 있음) T false
( 2 ) a
( 3 ) (비어 있음) std:: forward < U > ( v ) U
( 4 ) a
( 5 ) (비어 있음) std:: forward < Args > ( args )
( 6 ) a
( 7 ) (비어 있음) ilist,
std:: forward < Args > ( args )
( 8 ) a
( 9 ) 아래 참조 * other
( other 가 값을 소유하는 경우에만)
other 가 소유한 객체의 타입 true ( other 가 valueless인 경우에만)
( 10 ) a
( 11 ) std :: move 
( other. alloc  )
소유권 이전
( other 가 값을 소유하는 경우에만)
( 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) 다음 값들 중 하나라도 false 인 경우, 프로그램은 형식 오류를 가집니다:

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

3-8) 다음 오버로드들은 다음 값들이 모두 true 인 경우에만 오버로드 해결에 참여합니다:
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) 다음 모든 조건이 만족될 때만 이러한 오버로드들이 오버로드 해결에 참여합니다:
5-8) 이 오버로드들은 다음 조건이 std:: is_same_v < std:: remove_cvref_t < U > , U > 일 때만 오버로드 해결에 참여합니다.

예외

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

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

예제

참고 항목

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