Namespaces
Variants

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

#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[edit]
accesses an element of an integer_sequence
(function template) [edit]
obtains the type of the elements of integer_sequence
(class template specialization) [edit]
obtains the number of elements of a tuple-like type
(class template) [edit]
returns the size of reflected tuple-like type
(function) [edit]
obtains the size of an array
(class template specialization) [edit]
obtains the size of a pair
(class template specialization) [edit]
obtains the size of a tuple
(class template specialization) [edit]
obtains the size of a std::ranges::subrange
(class template specialization) [edit]
obtains the size of a std::complex
(class template specialization) [edit]