From Jason Turner

[intseq]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfm3a6jz3/{from.md → to.md} +52 -0
tmp/tmpfm3a6jz3/{from.md → to.md} RENAMED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Compile-time integer sequences <a id="intseq">[[intseq]]</a>
2
+
3
+ ### In general <a id="intseq.general">[[intseq.general]]</a>
4
+
5
+ The library provides a class template that can represent an integer
6
+ sequence. When used as an argument to a function template the parameter
7
+ pack defining the sequence can be deduced and used in a pack expansion.
8
+
9
+ ``` cpp
10
+ template<class F, class Tuple, std::size_t... I>
11
+ decltype(auto) apply_impl(F&& f, Tuple&& t, index_sequence<I...>) {
12
+ return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);
13
+ }
14
+
15
+ template<class F, class Tuple>
16
+ decltype(auto) apply(F&& f, Tuple&& t) {
17
+ using Indices = make_index_sequence<std::tuple_size<std::decay_t<Tuple>>::value>;
18
+ return apply_impl(std::forward<F>(f), std::forward<Tuple>(t), Indices());
19
+ }
20
+ ```
21
+
22
+ The `index_sequence` alias template is provided for the common case of
23
+ an integer sequence of type `size_t`.
24
+
25
+ ### Class template `integer_sequence` <a id="intseq.intseq">[[intseq.intseq]]</a>
26
+
27
+ ``` cpp
28
+ namespace std {
29
+ template<class T, T... I>
30
+ struct integer_sequence {
31
+ typedef T value_type;
32
+ static constexpr size_t size() noexcept { return sizeof...(I); }
33
+ };
34
+ }
35
+ ```
36
+
37
+ `T` shall be an integer type.
38
+
39
+ ### Alias template `make_integer_sequence` <a id="intseq.make">[[intseq.make]]</a>
40
+
41
+ ``` cpp
42
+ template<class T, T N>
43
+ using make_integer_sequence = integer_sequence<T, see below>;
44
+ ```
45
+
46
+ If `N` is negative the program is ill-formed. The alias template
47
+ `make_integer_sequence` denotes a specialization of `integer_sequence`
48
+ with `N` template non-type arguments. The type
49
+ `make_integer_sequence<T, N>` denotes the type
50
+ `integer_sequence<T, 0, 1, ..., N-1>`. `make_integer_sequence<int, 0>`
51
+ denotes the type `integer_sequence<int>`
52
+