From Jason Turner

[variant.helper]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfdli91lr/{from.md → to.md} +49 -0
tmp/tmpfdli91lr/{from.md → to.md} RENAMED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### `variant` helper classes <a id="variant.helper">[[variant.helper]]</a>
2
+
3
+ ``` cpp
4
+ template <class T> struct variant_size;
5
+ ```
6
+
7
+ *Remarks:* All specializations of `variant_size` shall meet the
8
+ `UnaryTypeTrait` requirements ([[meta.rqmts]]) with a base
9
+ characteristic of `integral_constant<size_t, N>` for some `N`.
10
+
11
+ ``` cpp
12
+ template <class T> class variant_size<const T>;
13
+ template <class T> class variant_size<volatile T>;
14
+ template <class T> class variant_size<const volatile T>;
15
+ ```
16
+
17
+ Let `VS` denote `variant_size<T>` of the cv-unqualified type `T`. Then
18
+ each of the three templates shall meet the `UnaryTypeTrait`
19
+ requirements ([[meta.rqmts]]) with a base characteristic of
20
+ `integral_constant<size_t, VS::value>`.
21
+
22
+ ``` cpp
23
+ template <class... Types>
24
+ struct variant_size<variant<Types...>> : integral_constant<size_t, sizeof...(Types)> { };
25
+ ```
26
+
27
+ ``` cpp
28
+ template <size_t I, class T> class variant_alternative<I, const T>;
29
+ template <size_t I, class T> class variant_alternative<I, volatile T>;
30
+ template <size_t I, class T> class variant_alternative<I, const volatile T>;
31
+ ```
32
+
33
+ Let `VA` denote `variant_alternative<I, T>` of the cv-unqualified type
34
+ `T`. Then each of the three templates shall meet the
35
+ `TransformationTrait` requirements ([[meta.rqmts]]) with a member
36
+ typedef `type` that names the following type:
37
+
38
+ - for the first specialization, `add_const_t<VA::type>`,
39
+ - for the second specialization, `add_volatile_t<VA::type>`, and
40
+ - for the third specialization, `add_cv_t<VA::type>`.
41
+
42
+ ``` cpp
43
+ variant_alternative<I, variant<Types...>>::type
44
+ ```
45
+
46
+ *Requires:* `I < sizeof...(Types)`.
47
+
48
+ *Value:* The type `T_I`.
49
+