mmon vocabulary types  
|  [ pair  ](/w/cpp/utility/pair "cpp/utility/pair")  
---  
[ tuple  ](/w/cpp/utility/tuple "cpp/utility/tuple") (C++11)  
[ optional  ](/w/cpp/utility/optional "cpp/utility/optional") (C++17)  
[ any  ](/w/cpp/utility/any "cpp/utility/any") (C++17)  
[ variant  ](/w/cpp/utility/variant "cpp/utility/variant") (C++17)  
  
|  ** tuple_size  ** (C++11)  
---  
[ tuple_element  ](/w/cpp/utility/tuple_element "cpp/utility/tuple element")
(C++11)  
[ apply  ](/w/cpp/utility/apply "cpp/utility/apply") (C++17)  
[ make_from_tuple  ](/w/cpp/utility/make_from_tuple "cpp/utility/make from
tuple") (C++17)  
[ expected  ](/w/cpp/utility/expected "cpp/utility/expected") (C++23)  
  
[ Elementary string conversions ](/w/cpp/utility#Elementary_string_conversions
"cpp/utility")  
|  [ to_chars  ](/w/cpp/utility/to_chars "cpp/utility/to chars") (C++17)  
---  
[ from_chars  ](/w/cpp/utility/from_chars "cpp/utility/from chars") (C++17)  
[ chars_format  ](/w/cpp/utility/chars_format "cpp/utility/chars format")
(C++17)  
  
|  [ to_chars_result  ](/w/cpp/utility/to_chars_result "cpp/utility/to chars
result") (C++17)  
---  
[ from_chars_result  ](/w/cpp/utility/from_chars_result "cpp/utility/from
chars result") (C++17)  
  
  
  
  
  
  
[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/utility/navbar_content&action=edit)

Defined in header ` [ <tuple> ](/w/cpp/header/tuple "cpp/header/tuple") ` |  |   
---|---|---  
Defined in header ` [ <array> ](/w/cpp/header/array "cpp/header/array") ` |  |   
Defined in header ` [ <utility> ](/w/cpp/header/utility "cpp/header/utility") ` |  |   
Defined in header ` [ <ranges> ](/w/cpp/header/ranges "cpp/header/ranges") ` |  |  (since C++20)   
template  < class  T  >  
struct  tuple_size  ;  // not defined  |  (1)  |  (since C++11)   
template  < class  T  >  
struct  tuple_size  < const  T  >  
:  [ std::  integral_constant  ](http://en.cppreference.com/w/cpp/types/integral_constant) < [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) , std  ::  tuple_size  < T  > ::  value  > {  }  ;  |  (2)  |  (since C++11)   
template  < class  T  >  
struct  tuple_size  < volatile  T  >  
:  [ std::  integral_constant  ](http://en.cppreference.com/w/cpp/types/integral_constant) < [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) , std  ::  tuple_size  < T  > ::  value  > {  }  ;  |  (3)  |  (since C++11)    
(deprecated in C++20)  
template  < class  T  >  
struct  tuple_size  < const  volatile  T  >  
:  [ std::  integral_constant  ](http://en.cppreference.com/w/cpp/types/integral_constant) < [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) , std  ::  tuple_size  < T  > ::  value  > {  }  ;  |  (4)  |  (since C++11)    
(deprecated in C++20)  
|  |   
  
Provides access to the number of elements in a [ tuple-like
](/w/cpp/utility/tuple/tuple-like "cpp/utility/tuple/tuple-like") type as a
compile-time constant expression.

1)  The primary template is not defined. An explicit (full) or partial
specialization is required to make a type tuple-like.

2-4)  Specializations for a cv-qualified types reuse the ` value ` from the
corresponding cv-unqualified versions by default.

` std::tuple_size ` interacts with the core language: it can provide [
structured binding ](/w/cpp/language/structured_binding
"cpp/language/structured binding") support in the tuple-like case.  (2-4)  are
SFINAE-friendly: if  std  ::  tuple_size  < T  > ::  value  is ill-formed when
treated as an unevaluated operand, they do not provide the member ` value ` .
Access checking is performed as if in a context unrelated to ` tuple_size `
and ` T ` . Only the validity of the immediate context of the expression is
considered. This allows

    
    
    #include <utility>
     
    struct X { int a, b; };
    const auto [x, y] = X(); // structured binding declaration first attempts
                             // tuple_size<const X> which attempts to use tuple