From Jason Turner

[variant.status]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpajkyhrnm/{from.md → to.md} +31 -0
tmp/tmpajkyhrnm/{from.md → to.md} RENAMED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Value status <a id="variant.status">[[variant.status]]</a>
2
+
3
+ ``` cpp
4
+ constexpr bool valueless_by_exception() const noexcept;
5
+ ```
6
+
7
+ *Effects:* Returns `false` if and only if the `variant` holds a value.
8
+
9
+ [*Note 1*:
10
+
11
+ A `variant` might not hold a value if an exception is thrown during a
12
+ type-changing assignment or emplacement. The latter means that even a
13
+ `variant<float, int>` can become `valueless_by_exception()`, for
14
+ instance by
15
+
16
+ ``` cpp
17
+ struct S { operator int() { throw 42; }};
18
+ variant<float, int> v{12.f};
19
+ v.emplace<1>(S());
20
+ ```
21
+
22
+ — *end note*]
23
+
24
+ ``` cpp
25
+ constexpr size_t index() const noexcept;
26
+ ```
27
+
28
+ *Effects:* If `valueless_by_exception()` is `true`, returns
29
+ `variant_npos`. Otherwise, returns the zero-based index of the
30
+ alternative of the contained value.
31
+