3

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.

user229044
  • 232,980
  • 40
  • 330
  • 338
Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173

3 Answers3

10

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

See documentation.

dalle
  • 18,057
  • 5
  • 57
  • 81
3

Check the doccumentation here.

length<T>::value

gives the length of the tuple type T.

Alok Save
  • 202,538
  • 53
  • 430
  • 533
2

According to boost::tuple documentation what you are looking for is length<T>::value

6502
  • 112,025
  • 15
  • 165
  • 265