std::expected<T,E>::emplace
From cppreference.com
| プライマリテンプレート |
||
| 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から) |
expected の値をインプレースで構築します。呼び出し後、has_value() は true を返します。
このオーバーロードは、std::is_nothrow_constructible_v<T, Args...> が true の場合にのみ、オーバーロード解決に参加します。
このオーバーロードは、std::is_nothrow_constructible_v<T, std::initializer_list<U>&, Args...> が true の場合にのみ、オーバーロード解決に参加します。
3) *this が unexpected 値を格納している場合、その値を破棄します。
目次 |
[編集] パラメータ
| 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= を使用できます。
[編集] 例
| このセクションは未完成です 理由: 例がありません |
[編集] 関連項目
| 内容を代入する (public member function) |