std::experimental::unique_resource<R, D>:: unique_resource
unique_resource
(
)
;
|
(1) | (library fundamentals TS v3) |
template
<
class
RR,
class
DD
>
unique_resource ( RR && r, DD && d ) noexcept ( /*see below*/ ) |
(2) | (library fundamentals TS v3) |
unique_resource
(
unique_resource
&&
other
)
;
|
(3) | (library fundamentals TS v3) |
Follow items are used for explanatory purpose:
-
RS
is the type of stored resource handle. - The expression res_ refers the underlying resource handle.
-
del_
refers the deleter object.
unique_resource
does not own the resource.
Then, the deleter is initialized with std:: forward < DD > ( d ) if std:: is_nothrow_constructible_v < D, DD > is true , otherwise d . If initialization of deleter throws an exception, calls d ( res_ ) .
The constructed
unique_resource
owns the resource.
std::move
if
std::
is_nothrow_move_constructible_v
<
RS
>
is
true
. If initialization of the stored resource handle throws an exception,
other
is not modified.
Then, the deleter is initialized with the one of other , using
std::move
if
std::
is_nothrow_move_constructible_v
<
D
>
is
true
. If initialization of the deleter throws an exception and
std::
is_nothrow_move_constructible_v
<
RS
>
is
true
and
other
owns the resource, calls the deleter of
other
with
res_
to dispose the resource, then calls
other.
release
(
)
.
After construction, the constructed
unique_resource
owns its resource if and only if
other
owned the resource before the construction, and
other
is set to not own the resource.
Parameters
r | - | a resource handle |
d | - | a deleter to use to dispose the resource |
other | - |
another
unique_resource
to acquire the ownership from
|
Exceptions
Any exception thrown during initialization of the stored resource handle or the deleter.
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
>
Notes
The mechanism of these constructors ensures no leaking of resources.
Example
This section is incomplete
Reason: no example |
See also
constructs a new
unique_ptr
(public member function of
std::unique_ptr<T,Deleter>
)
|