From Jason Turner

[variant.variant.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpyklhd9pg/{from.md → to.md} +69 -0
tmp/tmpyklhd9pg/{from.md → to.md} RENAMED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### General <a id="variant.variant.general">[[variant.variant.general]]</a>
2
+
3
+ ``` cpp
4
+ namespace std {
5
+ template<class... Types>
6
+ class variant {
7
+ public:
8
+ // [variant.ctor], constructors
9
+ constexpr variant() noexcept(see below);
10
+ constexpr variant(const variant&);
11
+ constexpr variant(variant&&) noexcept(see below);
12
+
13
+ template<class T>
14
+ constexpr variant(T&&) noexcept(see below);
15
+
16
+ template<class T, class... Args>
17
+ constexpr explicit variant(in_place_type_t<T>, Args&&...);
18
+ template<class T, class U, class... Args>
19
+ constexpr explicit variant(in_place_type_t<T>, initializer_list<U>, Args&&...);
20
+
21
+ template<size_t I, class... Args>
22
+ constexpr explicit variant(in_place_index_t<I>, Args&&...);
23
+ template<size_t I, class U, class... Args>
24
+ constexpr explicit variant(in_place_index_t<I>, initializer_list<U>, Args&&...);
25
+
26
+ // [variant.dtor], destructor
27
+ constexpr ~variant();
28
+
29
+ // [variant.assign], assignment
30
+ constexpr variant& operator=(const variant&);
31
+ constexpr variant& operator=(variant&&) noexcept(see below);
32
+
33
+ template<class T> constexpr variant& operator=(T&&) noexcept(see below);
34
+
35
+ // [variant.mod], modifiers
36
+ template<class T, class... Args>
37
+ constexpr T& emplace(Args&&...);
38
+ template<class T, class U, class... Args>
39
+ constexpr T& emplace(initializer_list<U>, Args&&...);
40
+ template<size_t I, class... Args>
41
+ constexpr variant_alternative_t<I, variant<Types...>>& emplace(Args&&...);
42
+ template<size_t I, class U, class... Args>
43
+ constexpr variant_alternative_t<I, variant<Types...>>&
44
+ emplace(initializer_list<U>, Args&&...);
45
+
46
+ // [variant.status], value status
47
+ constexpr bool valueless_by_exception() const noexcept;
48
+ constexpr size_t index() const noexcept;
49
+
50
+ // [variant.swap], swap
51
+ constexpr void swap(variant&) noexcept(see below);
52
+ };
53
+ }
54
+ ```
55
+
56
+ Any instance of `variant` at any given time either holds a value of one
57
+ of its alternative types or holds no value. When an instance of
58
+ `variant` holds a value of alternative type `T`, it means that a value
59
+ of type `T`, referred to as the `variant` object’s *contained value*, is
60
+ allocated within the storage of the `variant` object. Implementations
61
+ are not permitted to use additional storage, such as dynamic memory, to
62
+ allocate the contained value.
63
+
64
+ All types in `Types` shall meet the *Cpp17Destructible* requirements (
65
+ [[cpp17.destructible]]).
66
+
67
+ A program that instantiates the definition of `variant` with no template
68
+ arguments is ill-formed.
69
+