[variant.helper]

# 22 General utilities library [[utilities]](./#utilities)

## 22.6 Variants [[variant]](variant#helper)

### 22.6.4 variant helper classes [variant.helper]

[ð](#lib:variant_size)

`template<class T> struct variant_size;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6456)

All specializations of variant_size meet the[*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2 Requirements [meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements"))
with a base characteristic of integral_constant<size_t, N> for some N[.](#1.sentence-1)

[ð](#lib:variant_size_)

`template<class T> struct variant_size<const T>;
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6468)

Let VS denote variant_size<T> of the cv-unqualified
type T[.](#2.sentence-1)

Then each specialization of the template meets the[*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2 Requirements [meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements")) with a
base characteristic of integral_constant<size_t, VS​::​value>[.](#2.sentence-2)

[ð](#lib:variant_size__)

`template<class... Types>
  struct variant_size<variant<Types...>> : integral_constant<size_t, sizeof...(Types)> { };
`

[ð](#lib:variant_alternative)

`template<size_t I, class T> struct variant_alternative<I, const T>;
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6488)

Let VA denote variant_alternative<I, T> of the
cv-unqualified type T[.](#3.sentence-1)

Then each specialization of the template
meets the [*Cpp17TransformationTrait*](meta.rqmts#:Cpp17TransformationTrait "21.3.2 Requirements [meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements")) with a
member typedef type that names the type add_const_t<VA​::​type>[.](#3.sentence-2)

[ð](#lib:variant_alternative_)

`variant_alternative<I, variant<Types...>>::type
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6501)

*Mandates*: I < sizeof...(Types)[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6505)

*Type*: The type TI[.](#5.sentence-1)
