#include <array>
    #include <cstddef>
    #include <ranges>
    #include <tuple>
    #include <utility>
     
    template<class T, [std::size_t](http://en.cppreference.com/w/cpp/types/size_t) Size> struct Arr { T data[Size]; };
    // a program-defined specialization of std::tuple_size:
    template<class T, [std::size_t](http://en.cppreference.com/w/cpp/types/size_t) Size> struct std::tuple_size<Arr<T, Size>>
        : public integral_constant<[std::size_t](http://en.cppreference.com/w/cpp/types/size_t), Size> {};
     
    int main()
    {
        using tuple1 = [std::tuple](http://en.cppreference.com/w/cpp/utility/tuple)<int, char, double>;
        static_assert(3 == std::tuple_size_v<tuple1>); // uses using template (C++17)
     
        using array3x4 = [std::array](http://en.cppreference.com/w/cpp/container/array)<[std::array](http://en.cppreference.com/w/cpp/container/array)<int, 3>, 4>;
        static_assert(4 == std::tuple_size<array3x4>{}); // uses operator std::size_t
     
        using pair = [std::pair](http://en.cppreference.com/w/cpp/utility/pair)<tuple1, array3x4>;
        static_assert(2 == std::tuple_size<pair>()); // uses operator()
     
        using sub = std::[ranges::subrange](http://en.cppreference.com/w/cpp/ranges/subrange)<char*, char*>;
        static_assert(2 == std::tuple_size<sub>::value);
     
        using Arr5 = Arr<int, 5>;
        static_assert(5 == std::tuple_size_v<Arr5>);
    }

###  [ [ edit
](/mwiki/index.php?title=cpp/utility/tuple_size&action=edit&section=4 "Edit
section: Defect reports") ]  Defect reports

The following behavior-changing defect reports were applied retroactively to
previously published C++ standards.

DR  |  Applied to  |  Behavior as published  |  Correct behavior   
---|---|---|---  
[ LWG 2212 ](https://cplusplus.github.io/LWG/issue2212) |  C++11  |  specializations for cv types were not required in some headers, which led to ambiguity  |  required   
  
###  [ [ edit
](/mwiki/index.php?title=cpp/utility/tuple_size&action=edit&section=5 "Edit
section: See also") ]  See also

[ Structured binding ](/w/cpp/language/structured_binding "cpp/language/structured binding") (C++17)  |  binds the specified names to sub-objects or tuple elements of the initializer  [ [edit] ](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/language/dsc_structured_binding&action=edit)  
---|---  
[ tuple_element  ](/w/cpp/utility/tuple_element "cpp/utility/tuple element") (C++11)  |  obtains the element types of a tuple-like type   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/utility/dsc_tuple_element&action=edit)  
[ tuple_cat  ](/w/cpp/utility/tuple/tuple_cat "cpp/utility/tuple/tuple cat") (C++11)  |  creates a ` tuple ` by concatenating any number of tuples   
(function template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/utility/tuple/dsc_tuple_cat&action=edit)  
  
Retrieved from " [
https://en.cppreference.com/mwiki/index.php?title=cpp/utility/tuple_size&oldid=152393
](https://en.cppreference.com/mwiki/index.php?title=cpp/utility/tuple_size&oldid=152393)
"

#####  Navigation

  * [ Support us ](http://www.cppreference.com/support)
  * [ Recent changes ](/w/Special:RecentChanges "A list of recent changes in the wiki \[r\]")
  * [ FAQ ](/w/Cppreference:FAQ)
  * [ Offline version ](/w/Cppreference:Archives)

#####  Toolbox

  * [ What links here ](/w/Special:WhatLinksHere/cpp/utility/tuple_size "A list of all wiki pages that link here \[j\]")
  * [ Related changes ](/w/Special:RecentChangesLinked/cpp/utility/tuple_size "Recent changes in pages linked from this page \[k\]")
  * [ Upload file ](http://upload.cppreference.com/w/Special:Upload "Upload files \[u\]")
  * [ Special pages ](/w/Special:SpecialPages "A list of all special pages \[q\]")
  * [ Printable version ](/mwiki/index.php?title=cpp/utility/tuple_size&printable=yes "Printable version of this page \[p\]")
  * [ Permane