_size<X>::value,
                             // then soft error encountered, binds to public data members

|  (since C++17)  
---|---  
  
##  Contents

  * 1  Specializations 
  * 2  Helper variable template 
  * 3  Inherited from  std::  integral_constant 
    * 3.1  Member constants 
    * 3.2  Member functions 
    * 3.3  Member types 
    * 3.4  Example 
    * 3.5  Defect reports 
    * 3.6  See also 

  
---  
  
###  [ [ edit
](/mwiki/index.php?title=cpp/utility/tuple_size&action=edit&section=1 "Edit
section: Specializations") ]  Specializations

The standard library provides following specializations for standard library
types:

[ std::tuple_size  <std::tuple> ](/w/cpp/utility/tuple/tuple_size "cpp/utility/tuple/tuple size") (C++11)  |  obtains the size of ` tuple ` at compile time   
(class template specialization)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/utility/tuple/dsc_tuple_size&action=edit)  
---|---  
[ std::tuple_size  <std::pair> ](/w/cpp/utility/pair/tuple_size "cpp/utility/pair/tuple size") (C++11)  |  obtains the size of a ` pair `   
(class template specialization)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/utility/pair/dsc_tuple_size&action=edit)  
[ std::tuple_size  <std::array> ](/w/cpp/container/array/tuple_size "cpp/container/array/tuple size") (C++11)  |  obtains the size of an ` array `   
(class template specialization)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/container/array/dsc_tuple_size&action=edit)  
[ std::tuple_size  <std::ranges::subrange> ](/w/cpp/ranges/subrange/tuple_size "cpp/ranges/subrange/tuple size") (C++20)  |  obtains the number of components of a  [ std::ranges::subrange ](/w/cpp/ranges/subrange "cpp/ranges/subrange")   
(class template specialization)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/subrange/dsc_tuple_size&action=edit)  
  
All specializations of ` std::tuple_size ` satisfy [ UnaryTypeTrait
](/w/cpp/named_req/UnaryTypeTrait "cpp/named req/UnaryTypeTrait") with _base
characteristic_ [ std::  integral_constant
](http://en.cppreference.com/w/cpp/types/integral_constant) < [ std::  size_t
](http://en.cppreference.com/w/cpp/types/size_t) , N  > for some ` N ` .

Users may specialize ` std::tuple_size ` for program-defined types to make
them tuple-like. Program-defined specializations must meet the requirements
above.

Usually only specialization for cv-unqualified types are needed to be
customized.

###  [ [ edit
](/mwiki/index.php?title=cpp/utility/tuple_size&action=edit&section=2 "Edit
section: Helper variable template") ]  Helper variable template

Defined in header ` [ <tuple> ](/w/cpp/header/tuple "cpp/header/tuple") ` |  |   
---|---|---  
template  < class  T  >  
inline  constexpr  [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) tuple_size_v  =  tuple_size  < T  > ::  value  ;  |  |  (since C++17)   
|  |   
  
##  Inherited from [ std::  integral_constant ](/w/cpp/types/integral_constant
"cpp/types/integral constant")

###  Member constants

value  [static]  |  for a standard specialization, the number of elements in the tuple-like type ` T `   
(public static member constant)  
---|---  
  
###  Member functions

operator std::size_t  |  converts the object to  [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) , returns  value    
(public member function)  
---|---  
operator()  (C++14)  |  returns  value    
(public member function)  
  
###  Member types

Type  |  Definition   
---|---  
` value_type ` |  [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t)  
` type ` |  [ std::  integral_constant  ](http://en.cppreference.com/w/cpp/types/integral_constant) < [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) , value  >  
  
###  [ [ edit
](/mwiki/index.php?title=cpp/utility/tuple_size&action=edit&section=3 "Edit
section: Example") ]  Example

Run this code