[meta.unary.prop.query]

# 21 Metaprogramming library [[meta]](./#meta)

## 21.3 Metaprogramming and type traits [[type.traits]](type.traits#meta.unary.prop.query)

### 21.3.7 Type property queries [meta.unary.prop.query]

[1](#1)

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

The templates specified in Table [55](#tab:meta.unary.prop.query "Table 55: Type property queries") may be used to query properties of types at compile time[.](#1.sentence-1)

Table [55](#tab:meta.unary.prop.query) — Type property queries [[tab:meta.unary.prop.query]](./tab:meta.unary.prop.query)  

| [ð](#tab:meta.unary.prop.query-row-1)<br>**Template** | **Value** |
| --- | --- |
| [ð](#tab:meta.unary.prop.query-row-2)<br>template<class T>   struct alignment_of; | alignof(T)[.](#tab:meta.unary.prop.query-row-2-column-2-sentence-1)<br>   *Mandates*: alignof(T) is a valid expression ([[expr.alignof]](expr.alignof "7.6.2.6 Alignof")) |
| [ð](#tab:meta.unary.prop.query-row-3)<br>template<class T>   struct rank; | If T is an array type, an integer value representing  the number of dimensions of T; otherwise, 0[.](#tab:meta.unary.prop.query-row-3-column-2-sentence-1) |
| [ð](#tab:meta.unary.prop.query-row-4)<br>template<class T,   unsigned I = 0>   struct extent; | If T is not an array type, or if it has rank less  than or equal to I, or if I is 0 and T  has type âarray of unknown bound of Uâ, then  0; otherwise, the bound ([[dcl.array]](dcl.array "9.3.4.5 Arrays")) of the Ith dimension of T, where indexing of I is zero-based |

[2](#2)

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

Each of these templates shall be a [*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2 Requirements [meta.rqmts]") ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements")) with a
base characteristic of integral_constant<size_t, Value>[.](#2.sentence-1)

[3](#3)

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

[*Example [1](#example-1)*: // the following assertions hold:static_assert(rank_v<int> == 0);static_assert(rank_v<int[2]> == 1);static_assert(rank_v<int[][4]> == 2); â *end example*]

[4](#4)

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

[*Example [2](#example-2)*: // the following assertions hold:static_assert(extent_v<int> == 0);static_assert(extent_v<int[2]> == 2);static_assert(extent_v<int[2][4]> == 2);static_assert(extent_v<int[][4]> == 0);static_assert(extent_v<int, 1> == 0);static_assert(extent_v<int[2], 1> == 0);static_assert(extent_v<int[2][4], 1> == 4);static_assert(extent_v<int[][4], 1> == 4); â *end example*]
