In this C++ tutorial, you will learn how to get the size of a tuple, with example programs.

C++ Tuple Size

tuple_size gives access to the number of elements in a given Tuple.

In this tutorial, we will learn how to get the size of a tuple using tuple_size with examples.


The syntax of expression using tuple_size, to get the size of tuple x is



In the following program, we declared a Tuple with three elements. We shall get the size of this Tuple programmatically using tuple_size.

C++ Program

#include <iostream>
using namespace std;

int main() {
    tuple<int, string, bool> fruit(12, "apple", true);
    int size = tuple_size<decltype(fruit)>::value;
    cout << "Tuple Size : " << size << endl;


Tuple Size : 3
Program ended with exit code: 0


In this C++ Tutorial, we learned how to get the size of a Tuple using tuple_size, with the help of example.