Files
2025-10-25 03:02:53 +03:00

64 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[intseq]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.2 Compile-time integer sequences [intseq]
### [21.2.1](#general) General [[intseq.general]](intseq.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L21)
The library provides a class template that can represent an integer sequence[.](#general-1.sentence-1)
When used as an argument to a function template the template parameter pack defining the
sequence can be deduced and used in a pack expansion[.](#general-1.sentence-2)
[*Note [1](#general-note-1)*:
The index_sequence alias template is provided for the common case of
an integer sequence of type size_t; see also [[tuple.apply]](tuple.apply "22.4.6Calling a function with a tuple of arguments")[.](#general-1.sentence-3)
— *end note*]
### [21.2.2](#intseq) Class template integer_sequence [[intseq.intseq]](intseq.intseq)
[🔗](#lib:integer_sequence)
namespace std {template<class T, T... I> struct integer_sequence {using value_type = T; static constexpr size_t size() noexcept { return sizeof...(I); }};}
[1](#intseq-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L43)
*Mandates*: T is an integer type[.](#intseq-1.sentence-1)
### [21.2.3](#make) Alias template make_integer_sequence [[intseq.make]](intseq.make)
[🔗](#lib:make_integer_sequence)
`template<class T, T N>
using make_integer_sequence = integer_sequence<T, see below>;
`
[1](#make-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L56)
*Mandates*: N ≥ 0[.](#make-1.sentence-1)
[2](#make-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L60)
The alias templatemake_integer_sequence denotes a specialization ofinteger_sequence with N constant template arguments[.](#make-2.sentence-1)
The type make_integer_sequence<T, N> is an alias for the typeinteger_sequence<T, 0, 1, …, N - 1>[.](#make-2.sentence-2)
[*Note [1](#make-note-1)*:
make_integer_sequence<int, 0> is an alias for the typeinteger_sequence<int>[.](#make-2.sentence-3)
— *end note*]