integer sequences  
** integer_sequence  ** (C++14)  
  
[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/meta/navbar_content&action=edit)

Defined in header ` [ <utility> ](/w/cpp/header/utility "cpp/header/utility") ` |  |   
---|---|---  
template  < class  T, T...  Ints  >  
class  integer_sequence  ;  |  |  (since C++14)   
|  |   
  
The class template ` std::integer_sequence ` represents a compile-time
sequence of integers. When used as an argument to a [ function template
](/w/cpp/language/function_template "cpp/language/function template") , the [
parameter pack ](/w/cpp/language/parameter_pack "cpp/language/parameter pack")
` Ints ` can be deduced and used in pack expansion.

##  Contents

  * 1  Template parameters 
  * 2  Member types 
  * 3  Member functions 
  * 4  std::integer_sequence::  size 
    * 4.1  Parameters 
    * 4.2  Return value 
    * 4.3  Helper templates 
    * 4.4  Notes 
    * 4.5  Example 
    * 4.6  See also 

  
---  
  
###  [ [ edit
](/mwiki/index.php?title=cpp/utility/integer_sequence&action=edit&section=1
"Edit section: Template parameters") ]  Template parameters

T  |  \-  |  an integer type to use for the elements of the sequence   
---|---|---  
...Ints  |  \-  |  a non-type parameter pack representing the sequence   
  
###  [ [ edit
](/mwiki/index.php?title=cpp/utility/integer_sequence&action=edit&section=2
"Edit section: Member types") ]  Member types

Member type  |  Definition   
---|---  
` value_type ` |  ` T `  
  
###  [ [ edit
](/mwiki/index.php?title=cpp/utility/integer_sequence&action=edit&section=3
"Edit section: Member functions") ]  Member functions

** size  ** [static]  |  returns the number of elements in ` Ints `   
(public static member function)  
---|---  
  
##  std::integer_sequence::  size

static  constexpr  [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) size  (  )  noexcept  ;  |  |   
---|---|---  
|  |   
  
Returns the number of elements in ` Ints ` . Equivalent to  sizeof...  (  Ints
)  .

###  Parameters

(none)

###  Return value

The number of elements in ` Ints ` .

###  [ [ edit
](/mwiki/index.php?title=cpp/utility/integer_sequence&action=edit&section=6
"Edit section: Helper templates") ]  Helper templates

A helper alias template ` **std::index_sequence** ` is defined for the common
case where ` T ` is  [ std::size_t ](/w/cpp/types/size_t "cpp/types/size t") :

template  < [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t)
...  Ints  >  
using  index_sequence  =  std  ::  integer_sequence  < [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) , Ints...  > ;  |  |   
---|---|---  
|  |   
  
Helper alias templates ` **std::make_integer_sequence** ` and `
**std::make_index_sequence** ` are defined to simplify creation of `
std::integer_sequence ` and ` std::index_sequence ` types, respectively, with
0, 1, 2, ..., ` N - 1 ` as ` Ints ` :

template  < class  T, T N  >  
using  make_integer_sequence  =  std  ::  integer_sequence  < T,  /* a sequence 0, 1, 2, ..., N-1 */  > ;  |  |   
---|---|---  
template  < [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t)
N  >  
using  make_index_sequence  =  std  ::  make_integer_sequence  < [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) , N  > ;  |  |   
|  |   
  
The program is ill-formed if ` N ` is negative. If ` N ` is zero, the
indicated type is ` integer_sequence<T> ` .

A helper alias template ` **std::index_sequence_for** ` is defined to convert
any type parameter pack into an index sequence of the same length:

template  < class  ...  T  >  
using  index_sequence_for  =  std  ::  make_index_sequence  < sizeof...  (  T  )  > ;  |  |   
---|---|---  
|  |   
  
###  [ [ edit
](/mwiki/index.php?title=cpp/utility/integer_sequence&action=edit&section=7
"Edit section: Notes") ]  Notes

[ Feature-test ](/w/cpp/utility/feature_test "cpp/utility/feature test") macro  |  Value  |  Std  |  Feature   
---|---|-