std::expected<T,E>:: expected
|
メインテンプレート
|
||
|
constexpr
expected
(
)
;
|
(1) | (C++23以降) |
|
constexpr
expected
(
const
expected
&
other
)
;
|
(2) | (C++23以降) |
|
constexpr
expected
(
expected
&&
other
)
noexcept
(
/* see below */
)
;
|
(3) | (C++23以降) |
|
template
<
class
U,
class
G
>
constexpr expected ( const expected < U, G > & other ) ; |
(4) |
(C++23以降)
(条件付き明示的) |
|
template
<
class
U,
class
G
>
constexpr expected ( expected < U, G > && other ) ; |
(5) |
(C++23以降)
(条件付き明示的) |
|
template
<
class
U
=
std::
remove_cv_t
<
T
>
>
constexpr explicit ( ! std:: is_convertible_v < U, T > ) expected ( U && v ) ; |
(6) | (C++23以降) |
|
template
<
class
G
>
constexpr
explicit
(
!
std::
is_convertible_v
<
const
G
&
, E
>
)
|
(7) | (C++23以降) |
|
template
<
class
G
>
constexpr
explicit
(
!
std::
is_convertible_v
<
G, E
>
)
|
(8) | (C++23以降) |
|
template
<
class
...
Args
>
constexpr explicit expected ( std:: in_place_t , Args && ... args ) ; |
(9) | (C++23以降) |
|
template
<
class
U,
class
...
Args
>
constexpr
explicit
|
(10) | (C++23以降) |
|
template
<
class
...
Args
>
constexpr explicit expected ( std:: unexpect_t , Args && ... args ) ; |
(11) | (C++23以降) |
|
template
<
class
U,
class
...
Args
>
constexpr
explicit
|
(12) | (C++23以降) |
|
void
部分特殊化
|
||
|
constexpr
expected
(
)
;
|
(13) | (C++23以降) |
|
constexpr
expected
(
const
expected
&
other
)
;
|
(14) | (C++23以降) |
|
constexpr
expected
(
expected
&&
other
)
noexcept ( std:: is_nothrow_move_constructible_v < E > ) ; |
(15) | (C++23以降) |
|
template
<
class
U,
class
G
>
constexpr
explicit
(
!
std::
is_convertible_v
<
const
G
&
, E
>
)
|
(16) | (C++23以降) |
|
template
<
class
U,
class
G
>
constexpr
explicit
(
!
std::
is_convertible_v
<
G, E
>
)
|
(17) | (C++23以降) |
|
template
<
class
G
>
constexpr
explicit
(
!
std::
is_convertible_v
<
const
G
&
, E
>
)
|
(18) | (C++23以降) |
|
template
<
class
G
>
constexpr
explicit
(
!
std::
is_convertible_v
<
G, E
>
)
|
(19) | (C++23以降) |
|
constexpr
explicit
expected
(
std::
in_place_t
)
;
|
(20) | (C++23以降) |
|
template
<
class
...
Args
>
constexpr explicit expected ( std:: unexpect_t , Args && ... args ) ; |
(21) | (C++23以降) |
|
template
<
class
U,
class
...
Args
>
constexpr
explicit
|
(22) | (C++23以降) |
新しい
expected
オブジェクトを構築します。
目次 |
パラメータ
| other | - |
別の
expected
オブジェクト。その含まれる値がコピーされる
|
| e | - |
std::unexpected
オブジェクト。その含まれる値がコピーされる
|
| v | - | 含まれる値を初期化するための値 |
| args | - | 含まれる値を初期化するための引数 |
| il | - | 含まれる値を初期化するための初期化子リスト |
効果
プライマリテンプレートコンストラクタ
| オーバーロード |
初期化
方法 |
初期化子の対象... |
has_value()
構築後の状態 |
|
|---|---|---|---|---|
| 期待値 | 予期せぬ値 | |||
| ( 1 ) | 値 | (空) | - | true |
| ( 2 ) |
直接初期化
(非リスト) |
* other | other. error ( ) |
other.
has_value
(
)
|
| ( 3 ) | std :: move ( * other ) | std :: move ( other. error ( ) ) | ||
| ( 3 ) | std :: move ( * other ) | std :: move ( other. error ( ) ) | ||
| ( 4 ) |
std::
forward
<
const
U
&
>
( * other ) |
std::
forward
<
const
G
&
>
( other. error ( ) ) |
||
| ( 5 ) | std:: forward < U > ( * other ) |
std::
forward
<
G
>
( other. error ( ) ) |
||
| ( 6 ) | std:: forward < U > ( v ) | - | true | |
| ( 7 ) | - |
std::
forward
<
const
G
&
>
( e. error ( ) ) |
false | |
| ( 8 ) | std:: forward < G > ( e. error ( ) ) | |||
| ( 9 ) | std:: forward < Args > ( args ) ... | - | true | |
| ( 10 ) |
il,
std:: forward < Args > ( args ) ... |
|||
| ( 10 ) |
il,
std:: forward < Args > ( args ) ... |
|||
| ( 11 ) | - | std:: forward < Args > ( args ) ... | false | |
| ( 12 ) |
il,
std:: forward < Args > ( args ) ... |
|||
| ( 12 ) |
il,
std:: forward < Args > ( args ) ... |
|||
void 部分特殊化コンストラクタ
| オーバーロード | 初期化方法 | 予期しない値の初期化子 |
has_value()
構築後の値
|
|---|---|---|---|
| ( 13 ) | N/A | - | true |
| ( 14 ) | 直接(非リスト) | rhs. error ( ) |
other.
has_value
(
)
|
| ( 15 ) | std :: move ( rhs. error ) | ||
| ( 16 ) | std:: forward < const G & > ( rhs. error ( ) ) | ||
| ( 17 ) | std:: forward < G > ( rhs. error ( ) ) | ||
| ( 18 ) | std:: forward < const G & > ( e. error ( ) ) | false | |
| ( 19 ) | std:: forward < G > ( e. error ( ) ) | ||
| ( 20 ) | N/A | - | true |
| ( 21 ) | 直接(非リスト) | std:: forward < Args > ( args ) ... | false |
| ( 22 ) | il, std:: forward < Args > ( args ) ... |
制約条件と補足情報
プライマリテンプレートコンストラクタ
- オーバーロード (4) の場合、 std:: is_constructible_v < T, const U & > および std:: is_constructible_v < E, const G & > がともに true である。
- オーバーロード (5) について、 std:: is_constructible_v < T, U > と std:: is_constructible_v < E, G > がともに true である場合。
-
Tが(CV修飾されている可能性のある) bool でない場合、以下の8つの値はすべて false となります:- std:: is_constructible_v < T, std:: expected < U, G > & >
- std:: is_constructible_v < T, std:: expected < U, G >>
- std:: is_constructible_v < T, const std:: expected < U, G > & >
- std:: is_constructible_v < T, const std:: expected < U, G >>
- std:: is_convertible_v < std:: expected < U, G > & , T >
- std:: is_convertible_v < std:: expected < U, G > , T >
- std:: is_convertible_v < const std:: expected < U, G > & , T >
- std:: is_convertible_v < const std:: expected < U, G > , T >
-
以下の4つの値はすべて
false
です:
- std:: is_constructible_v < std:: unexpected < E > , std:: expected < U, G > & >
- std:: is_constructible_v < std:: unexpected < E > , std:: expected < U, G >>
- std:: is_constructible_v < std:: unexpected < E > , const std:: expected < U, G > & >
- std:: is_constructible_v < std:: unexpected < E > , const std:: expected < U, G >>
- std:: is_same_v < std:: remove_cvref_t < U > , std:: in_place_t > が false であること。
- std:: is_same_v < std:: expected < T, E > , std:: remove_cvref_t < U >> が false であること。
- std:: is_constructible_v < T, U > が true であること。
-
std::
remove_cvref_t
<
U
>
が
std::unexpectedの特殊化ではないこと。 -
Tが(CV修飾されている可能性のある) bool である場合、 std:: remove_cvref_t < U > がstd::expectedの特殊化ではないこと。
void 部分特殊化コンストラクタ
- オーバーロード (16) については、 std:: is_constructible_v < E, const G & > が true であること。
- オーバーロード (17) については、 std:: is_constructible_v < E, G > が true であること。
- std:: is_void_v < U > が true であること。
-
以下の4つの値が全て
false
であること:
- std:: is_constructible_v < std:: unexpected < E > , std:: expected < U, G > & >
- std:: is_constructible_v < std:: unexpected < E > , std:: expected < U, G >>
- std:: is_constructible_v < std:: unexpected < E > , const std:: expected < U, G > & >
- std:: is_constructible_v < std:: unexpected < E > , const std:: expected < U, G >>
例外
プライマリテンプレートコンストラクタ
&& std:: is_nothrow_move_constructible_v < E > )
void 部分特殊化コンストラクタ
例
|
このセクションは不完全です
理由: 例がありません |
欠陥報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 3886 | C++23 |
overload
(
6
)
のデフォルトテンプレート引数は
T
であった
|
以下のように変更された std:: remove_cv_t < T > |
関連項目
|
(C++23)
|
予期しない値として表現される
(クラステンプレート) |
|
インプレース構築タグ
(タグ) |
|
|
(C++23)
|
expected
における予期しない値のインプレース構築タグ
(タグ) |