std::tuple_size<std::integer_sequence>
From cppreference.com
| Defined in header <utility>
|
||
template< class T, T... Values >
struct tuple_size<std::integer_sequence<T, Values...>>
: std::integral_constant<std::size_t, sizeof...(Values)> {};
|
(since C++26) | |
Provides access to the number of elements in an std::integer_sequence as a compile-time constant expression.
Inherited from std::integral_constant
Data members
value [static] |
sizeof...(Values), the number of elements in the integer sequence (public static member constant) |
Member functions
operator std::size_t |
converts the object to std::size_t, returns value (public member function) |
operator() (C++14) |
returns value (public member function) |
Nested types
| Type | Definition |
value_type
|
std::size_t
|
type
|
std::integral_constant<std::size_t, value>
|
Notes
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
__cpp_lib_integer_sequence |
202511L |
(C++26) | Tuple protocol for std::integer_sequence
|
Example
Run this code
#include <utility>
int main()
{
using seq = std::make_index_sequence<5>;
static_assert(std::tuple_size<seq>{} == 5);
// In C++26 structured bindings for std::integer_sequence
// also works, due to support of the full tuple protocol:
constexpr auto [zero, one, _, three, _] = seq{};
static_assert(zero == 0 and one == 1 and three == 3);
}
See also
| Structured binding (C++17) | binds the specified names to sub-objects or tuple elements of the initializer |
(C++26) |
accesses an element of an integer_sequence (function template) |
obtains the type of the elements of integer_sequence (class template specialization) |
(C++11) |
obtains the number of elements of a tuple-like type (class template) |
(C++26) |
returns the size of reflected tuple-like type (function) |
(C++11) |
obtains the size of an array (class template specialization) |
(C++11) |
obtains the size of a pair (class template specialization) |
(C++11) |
obtains the size of a tuple (class template specialization) |
| obtains the size of a std::ranges::subrange (class template specialization) | |
| obtains the size of a std::complex (class template specialization) |