Search code examples
c++tuplesboost-tuples

number of templated parameters in a boost::tuple


I am using boost::tuple for my code.

Suppose that I want to store an equivalent of a structure having 3 members

  typedef boost::tuple< std::string, int, double > my_struct;

Is there any way of method to call on the tuple that will give me the number of members contained so in this case 3?

My goal here is to monitor when I increase the number of template parameters.


Solution

  • Use the ::boost::tuples::length<T>::value helper function.

    See documentation.