std::expected<T,E>:: emplace
From cppreference.net
|
プライマリテンプレート
|
||
|
template
<
class
...
Args
>
constexpr T & emplace ( Args && ... args ) noexcept ; |
(1) | (C++23以降) |
|
template
<
class
U,
class
...
Args
>
constexpr T & emplace ( std:: initializer_list < U > il, Args && ... args ) noexcept ; |
(2) | (C++23以降) |
|
void
部分特殊化
|
||
|
constexpr
void
emplace
(
)
noexcept
;
|
(3) | (C++23以降) |
期待値をその場で構築します。呼び出し後、
has_value()
はtrueを返します。
1)
格納されている値を破棄し、その後
direct-initializes
*
this
に含まれる期待値を
std::
forward
<
Args
>
(
args
)
...
で直接初期化します。
このオーバーロードは、
std::
is_nothrow_constructible_v
<
T,
std::
initializer_list
<
U
>
&
, Args...
>
が
true
の場合にのみ、オーバーロード解決に参加します。
3)
*
this
が予期しない値を含む場合、その値を破棄する。
目次 |
パラメータ
| args | - | コンストラクタに渡す引数 |
| il | - | コンストラクタに渡す初期化子リスト |
戻り値
1)
*
std::
construct_at
(
std::
addressof
(
val
)
,
std::
forward
<
Args
>
(
args
)
...
)
2)
*
std::
construct_at
(
std::
addressof
(
val
)
, il,
std::
forward
<
Args
>
(
args
)
...
)
注記
T
の構築が例外を投げる可能性がある場合、
operator=
を代わりに使用できます。
例
|
このセクションは不完全です
理由: 例がありません |
関連項目
|
内容を代入
(公開メンバ関数) |