std::experimental::unique_resource<R, D>:: unique_resource
|
unique_resource
(
)
;
|
(1) | (라이브러리 fundamentals TS v3) |
|
template
<
class
RR,
class
DD
>
unique_resource ( RR && r, DD && d ) noexcept ( /*see below*/ ) |
(2) | (라이브러리 fundamentals TS v3) |
|
unique_resource
(
unique_resource
&&
other
)
;
|
(3) | (라이브러리 fundamentals TS v3) |
다음 항목들은 설명 목적으로 사용됩니다:
-
RS는 저장된 리소스 핸들의 유형입니다. - 표현식 res_ 은 기본 리소스 핸들을 참조합니다.
-
del_은 삭제자 객체를 참조합니다.
unique_resource
는 리소스를 소유하지 않습니다.
그런 다음, 삭제자는 std:: forward < DD > ( d ) 로 초기화됩니다 - 만약 std:: is_nothrow_constructible_v < D, DD > 가 true 인 경우, 그렇지 않으면 d 으로 초기화됩니다. 삭제자 초기화에서 예외가 발생하면 d ( res_ ) 를 호출합니다.
생성된
unique_resource
는 자원을 소유합니다.
std::move
를 사용합니다. 저장된 리소스 핸들의 초기화에서 예외가 발생하면
other
는 수정되지 않습니다.
그런 다음, 삭제자는 other 의 삭제자로부터 초기화되며, std:: is_nothrow_move_constructible_v < D > 가 true 인 경우
std::move
를 사용합니다. 삭제자의 초기화에서 예외가 발생하고
std::
is_nothrow_move_constructible_v
<
RS
>
가
true
이고
other
가 리소스를 소유하는 경우,
other
의 삭제자를
res_
와 함께 호출하여 리소스를 처리한 후
other.
release
(
)
를 호출합니다.
생성 후, 생성된
unique_resource
는 생성 전
other
가 리소스를 소유했던 경우에만 리소스를 소유하며,
other
는 리소스를 소유하지 않는 상태로 설정됩니다.
목차 |
매개변수
| r | - | 리소스 핸들 |
| d | - | 리소스를 해제하는 데 사용할 삭제자 |
| other | - |
소유권을 획득할 다른
unique_resource
|
예외
저장된 리소스 핸들 또는 삭제자의 초기화 중 발생하는 모든 예외.
std::
is_nothrow_constructible_v
<
RS, RR
>
||
std::
is_nothrow_constructible_v
<
RS, RR
&
>
)
&&
(
std::
is_nothrow_constructible_v
<
D, DD
>
||
std::
is_nothrow_constructible_v
<
D, DD
&
>
std::
is_nothrow_move_constructible_v
<
R1
>
&&
std::
is_nothrow_move_constructible_v
<
D
>
참고 사항
이러한 생성자들의 메커니즘은 자원 누출이 발생하지 않도록 보장합니다.
예제
|
이 섹션은 불완전합니다
이유: 예제가 없음 |
참고 항목
새로운
unique_ptr
을 생성함
(
std::unique_ptr<T,Deleter>
의 public 멤버 함수)
|