From Jason Turner

[variant.get]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptr0bjecx/{from.md → to.md} +7 -10
tmp/tmptr0bjecx/{from.md → to.md} RENAMED
@@ -3,15 +3,14 @@
3
  ``` cpp
4
  template<class T, class... Types>
5
  constexpr bool holds_alternative(const variant<Types...>& v) noexcept;
6
  ```
7
 
8
- *Requires:* The type `T` occurs exactly once in `Types...`. Otherwise,
9
- the program is ill-formed.
10
 
11
  *Returns:* `true` if `index()` is equal to the zero-based index of `T`
12
- in `Types...`.
13
 
14
  ``` cpp
15
  template<size_t I, class... Types>
16
  constexpr variant_alternative_t<I, variant<Types...>>& get(variant<Types...>& v);
17
  template<size_t I, class... Types>
@@ -20,11 +19,11 @@ template <size_t I, class... Types>
20
  constexpr const variant_alternative_t<I, variant<Types...>>& get(const variant<Types...>& v);
21
  template<size_t I, class... Types>
22
  constexpr const variant_alternative_t<I, variant<Types...>>&& get(const variant<Types...>&& v);
23
  ```
24
 
25
- *Requires:* `I < sizeof...(Types)`. Otherwise the program is ill-formed.
26
 
27
  *Effects:* If `v.index()` is `I`, returns a reference to the object
28
  stored in the `variant`. Otherwise, throws an exception of type
29
  `bad_variant_access`.
30
 
@@ -33,12 +32,11 @@ template <class T, class... Types> constexpr T& get(variant<Types...>& v);
33
  template<class T, class... Types> constexpr T&& get(variant<Types...>&& v);
34
  template<class T, class... Types> constexpr const T& get(const variant<Types...>& v);
35
  template<class T, class... Types> constexpr const T&& get(const variant<Types...>&& v);
36
  ```
37
 
38
- *Requires:* The type `T` occurs exactly once in `Types...`. Otherwise,
39
- the program is ill-formed.
40
 
41
  *Effects:* If `v` holds a value of type `T`, returns a reference to that
42
  value. Otherwise, throws an exception of type `bad_variant_access`.
43
 
44
  ``` cpp
@@ -48,11 +46,11 @@ template <size_t I, class... Types>
48
  template<size_t I, class... Types>
49
  constexpr add_pointer_t<const variant_alternative_t<I, variant<Types...>>>
50
  get_if(const variant<Types...>* v) noexcept;
51
  ```
52
 
53
- *Requires:* `I < sizeof...(Types)`. Otherwise the program is ill-formed.
54
 
55
  *Returns:* A pointer to the value stored in the `variant`, if
56
  `v != nullptr` and `v->index() == I`. Otherwise, returns `nullptr`.
57
 
58
  ``` cpp
@@ -62,11 +60,10 @@ template <class T, class... Types>
62
  template<class T, class... Types>
63
  constexpr add_pointer_t<const T>
64
  get_if(const variant<Types...>* v) noexcept;
65
  ```
66
 
67
- *Requires:* The type `T` occurs exactly once in `Types...`. Otherwise,
68
- the program is ill-formed.
69
 
70
  *Effects:* Equivalent to: `return get_if<`i`>(v);` with i being the
71
- zero-based index of `T` in `Types...`.
72
 
 
3
  ``` cpp
4
  template<class T, class... Types>
5
  constexpr bool holds_alternative(const variant<Types...>& v) noexcept;
6
  ```
7
 
8
+ *Mandates:* The type `T` occurs exactly once in `Types`.
 
9
 
10
  *Returns:* `true` if `index()` is equal to the zero-based index of `T`
11
+ in `Types`.
12
 
13
  ``` cpp
14
  template<size_t I, class... Types>
15
  constexpr variant_alternative_t<I, variant<Types...>>& get(variant<Types...>& v);
16
  template<size_t I, class... Types>
 
19
  constexpr const variant_alternative_t<I, variant<Types...>>& get(const variant<Types...>& v);
20
  template<size_t I, class... Types>
21
  constexpr const variant_alternative_t<I, variant<Types...>>&& get(const variant<Types...>&& v);
22
  ```
23
 
24
+ *Mandates:* `I` < `sizeof...(Types)`.
25
 
26
  *Effects:* If `v.index()` is `I`, returns a reference to the object
27
  stored in the `variant`. Otherwise, throws an exception of type
28
  `bad_variant_access`.
29
 
 
32
  template<class T, class... Types> constexpr T&& get(variant<Types...>&& v);
33
  template<class T, class... Types> constexpr const T& get(const variant<Types...>& v);
34
  template<class T, class... Types> constexpr const T&& get(const variant<Types...>&& v);
35
  ```
36
 
37
+ *Mandates:* The type `T` occurs exactly once in `Types`.
 
38
 
39
  *Effects:* If `v` holds a value of type `T`, returns a reference to that
40
  value. Otherwise, throws an exception of type `bad_variant_access`.
41
 
42
  ``` cpp
 
46
  template<size_t I, class... Types>
47
  constexpr add_pointer_t<const variant_alternative_t<I, variant<Types...>>>
48
  get_if(const variant<Types...>* v) noexcept;
49
  ```
50
 
51
+ *Mandates:* `I` < `sizeof...(Types)`.
52
 
53
  *Returns:* A pointer to the value stored in the `variant`, if
54
  `v != nullptr` and `v->index() == I`. Otherwise, returns `nullptr`.
55
 
56
  ``` cpp
 
60
  template<class T, class... Types>
61
  constexpr add_pointer_t<const T>
62
  get_if(const variant<Types...>* v) noexcept;
63
  ```
64
 
65
+ *Mandates:* The type `T` occurs exactly once in `Types`.
 
66
 
67
  *Effects:* Equivalent to: `return get_if<`i`>(v);` with i being the
68
+ zero-based index of `T` in `Types`.
69