Share via


tuple_size Class <array>

 

The latest version of this topic can be found at Visual Studio 2017 Documentation.

Wraps the size of an array.

Syntax

template <class Tuple>  
struct tuple_size;  
 
// struct to determine number of elements in array  
template <class T, size_t Size>  
struct tuple_size<array<T, Size>>  
: integral_constant<size_t, Size>;  
 
// size of const tuple  
template <class Tuple>  
struct tuple_size<const Tuple>;  
 
// size of volatile tuple  
template <class Tuple>  
struct tuple_size<volatile Tuple>;  
 
// size of const volatile tuple  
template <class Tuple>  
struct tuple_size<const volatile Tuple>;  

Template Parameters

T
The type of an element.

Size
The size of the array.

Remarks

This template is a specialization of the template class tuple_size Class. It has a member value that is an integral constant expression whose value is N, which is the size of the array.

Example

#include <array>   
#include <iostream>   
  
using namespace std;  
  
typedef array<int, 4> MyArray;  
  
int main()  
{  
    MyArray c0 { 0, 1, 2, 3 };  
  
    // display contents " 0 1 2 3"   
    for (const auto& e : c0)  
    {  
        cout << e;  
    }  
    cout << endl;  
  
    // display size " 4"   
    cout << " " << tuple_size<MyArray>::value << endl;  
}  
/*  
Output:  
0123  
4  
*/  
  

Requirements

Header: <array>

Namespace: std

See Also

<array>
<tuple>
tuple_size Class