Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The latest version of this topic can be found at Visual Studio 2017 Documentation.
Wraps pair element count.
Syntax
template <class Tuple>
struct tuple_size;
template <class T1, class T2>
struct tuple_size<pair<T1, T2>> : integral_constant<size_t, 2>
// 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>;
Parameters
T1
The type of the first pair element.
T2
The type of the second pair element.
Remarks
The 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 2.
Example
#include <utility>
#include <iostream>
using namespace std;
typedef pair<int, double> MyPair;
int main()
{
MyPair c0(0, 1.1);
// display contents " 0 1.1"
cout << " " << get<0>(c0);
cout << " " << get<1>(c0) << endl;
// display size " 2"
cout << " " << tuple_size<MyPair>::value << endl;
}
/*
Output:
0 1.1
2
*/
Requirements
Header: <utility>
Namespace: std