[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/utility/tuple/tuple_size [Back]  [Original]

std::tuple_size<std::tuple> cppreference.com
cppreference.com

std::tuple_size<std::tuple>

cppreference.com
 
C++
(C++20)
(C++20)
(C++11)
(C++20)
/
(C++11)
(C++11)
(C++11)
(C++17)
 
 
 
<tbody> </tbody>
template< class... Types > struct tuple_size< std::tuple<Types...> > : std::integral_constant<std::size_t, sizeof...(Types)> { };
( C++11)

tuple .

<tbody> </tbody>
template< class T > inline constexpr std::size_t tuple_size_v = tuple_size<T>::value;
( C++17)

std::integral_constant

value
[static]
sizeof...(Types)
(public static -)

-

operator std::size_t
std::size_t, value
(public -)
operator()
(C++14)
value
(public -)

value_type std::size_t
type std::integral_constant<std::size_t, value>

#include <iostream>
#include <tuple>

template <class T>
void test(T value)
{
    int a[std::tuple_size_v<T>]; //     

    std::cout << std::tuple_size<T>{} << ' ' //    
              << sizeof a << ' ' 
              << sizeof value << '\n';
}

int main()
{
    test(std::make_tuple(1, 2, 3.14));
}

:

3 12 16

(C++17) []
tuple
( ) []

( ) []

Web Proxy Viewer  |  New URL  |  Original Page