C++ Tuple Library - size


Advertisements

Description

It contains the information about tuple size.

Declaration

Following is the declaration for std::tuple_size.

C++98

	
template <class T> class tuple_size;

C++11

template <class T> class tuple_size;

Parameters

t − It contains type for which the tuple size is obtained.

Return Value

none

Exceptions

No-throw guarantee − this member function never throws exceptions.

Data races

The members of both tuple objects are modified.

Example

In below example for std::tuple_size.

#include <iostream>
#include <tuple>

int main () {
   std::tuple<int,int,char,double> mytuple (100,900,'a',3.14);

   std::cout << "tuple has ";
   std::cout << std::tuple_size<decltype(mytuple)>::value;
   std::cout << " elements." << '\n';

   return 0;
}

The output should be like this −

tuple has 4 elements.
tuple.htm
Advertisements