std::experimental::scope_exit<EF>:: scope_exit
From cppreference.net
<
cpp
|
experimental
|
scope exit
|
template
<
class
Fn
>
explicit scope_exit ( Fn && fn ) noexcept ( /*voir ci-dessous*/ ) ; |
(1) | (bibliothèque fundamentals TS v3) |
|
scope_exit
(
scope_exit
&&
other
)
noexcept
(
/*voir ci-dessous*/
)
;
|
(2) | (bibliothèque fundamentals TS v3) |
|
scope_exit
(
const
scope_exit
&
)
=
delete
;
|
(3) | (bibliothèque fundamentals TS v3) |
Crée un
scope_exit
à partir d'une fonction, d'un objet fonction ou d'un autre
scope_exit
.
1)
Initialise la fonction de sortie avec une fonction ou un objet fonction. Le
scope_exit
construit est actif.
Si
Fn
n'est pas un type référence lvalue et
std::
is_nothrow_constructible_v
<
EF, Fn
>
est
true
, le
EF
stocké est initialisé avec
std::
forward
<
Fn
>
(
fn
)
; sinon il est initialisé avec
fn
.
Si l'initialisation du stocké
EF
lève une exception, appelle
fn
(
)
.
Cette surcharge participe à la résolution de surcharge seulement si
std::
is_same_v
<
std::
remove_cvref_t
<
Fn
>
, scope_exit
>
est
false
et
std::
is_constructible_v
<
EF, Fn
>
est
true
.
Le programme est mal formé si l'expression d'appel de fonction
fn
(
)
est mal formée.
Le comportement est indéfini si l'appel de
fn
(
)
lève une exception ou entraîne un comportement indéfini, même si
fn
n'a pas été appelé.
2)
Constructeur de déplacement. Initialise le
EF
stocké avec celui dans
other
. Le
scope_exit
construit est actif si et seulement si
other
était actif avant la construction.
Si
std::
is_nothrow_move_constructible_v
<
EF
>
est
true
, initialise le
EF
stocké (désigné par
exitfun
) avec
std::
forward
<
EF
>
(
other.
exitfun
)
, sinon l'initialise avec
other.
exitfun
.
Après une construction par déplacement réussie,
other.
release
(
)
est appelé et
other
devient inactif.
Cette surcharge participe à la résolution de surcharge seulement si
std::
is_nothrow_move_constructible_v
<
EF
>
est
true
ou si
std::
is_copy_constructible_v
<
EF
>
est
true
.
Le comportement est indéfini si
-
std::
is_nothrow_move_constructible_v
<
EF
>
est
true
et
EFne satisfait pas aux exigences de MoveConstructible , ou -
std::
is_nothrow_move_constructible_v
<
EF
>
est
false
et
EFne satisfait pas aux exigences de CopyConstructible .
Table des matières |
Paramètres
| fn | - |
fonction ou objet fonction utilisé pour initialiser le
EF
stocké
|
| other | - |
scope_exit
à déplacer
|
Exceptions
Toute exception levée lors de l'initialisation du
EF
stocké.
1)
noexcept
spécification :
noexcept
(
std::
is_nothrow_constructible_v
<
EF, Fn
>
||
std:: is_nothrow_constructible_v < EF, Fn & > )
std:: is_nothrow_constructible_v < EF, Fn & > )
2)
noexcept
spécification :
noexcept
(
std::
is_nothrow_move_constructible_v
<
EF
>
||
std:: is_nothrow_copy_constructible_v < EF > )
std:: is_nothrow_copy_constructible_v < EF > )
Exemple
|
Cette section est incomplète
Raison : aucun exemple |
Voir aussi
rend le
scope_exit
inactif
(fonction membre publique) |