std::tuple_size<std:ranges::subrange>
From cppreference.com
 
 
 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Ranges library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
(C++23)(C++23)
  (C++26)(C++26)
(C++23)(C++23)
  (C++26)(C++26)
(C++26)(C++26)
  (C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
  (C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
std::ranges::subrange 
 
tuple_size<std::ranges::subrange>
Defined in header 
 
 
<ranges> 
 template< class I, class S, ranges::subrange_kind K >
 
 (since C++20) 
struct tuple_size<ranges::subrange <I, S, K>>
The partial specialization of std::tuple_size for std::ranges::subrange  provides a compile-time way to obtain the number of components of a subrange, which is always 2, using tuple-like syntax. It is provided for structured binding support.
Contents
Inherited from std::integral_constant
Member constants
value
[static]
(public static member constant)
Member functions
operator()
(C++14)
(public member function)
Member types
 Type
 Definition
value_type
 std::size_t 
type
 std::integral_constant <std::size_t, value>
[edit] Example
Run this code
#include <array> #include <iostream> #include <iterator> #include <ranges> int main() { static_assert(2 == std::tuple_size_v <std::ranges::subrange <int*, int*>>); using array5 = std::array <int, 5>; static_assert(2 == std::tuple_size <std::ranges::subrange < array5::const_iterator, array5::const_iterator>>{}); constexpr array5 a{1, 2, 3, 4, 5}; std::ranges::subrange sub_a1{a}; for (std::cout << "sub_a1: { "; int e : sub_a1) std::cout << e << ' '; std::cout << "}\n"; std::ranges::subrange sub_a2{std::next (cbegin(a)), std::prev (cend(a))}; const auto [first, last] = sub_a2; std::cout << "sub_a2 size = " << std::distance (first, last) << '\n'; for (std::cout << "sub_a2: { "; int e : sub_a2) std::cout << e << ' '; std::cout << "}\n"; }
Output:
sub_a1: { 1 2 3 4 5 }
sub_a2 size = 3
sub_a2: { 2 3 4 }[edit] See also
 Structured binding (C++17)
 binds the specified names to sub-objects or tuple elements of the initializer[edit] 
(C++11)
a tuple 
 (class template specialization) [edit] 
 
 obtains the type of the iterator or the sentinel of a std::ranges::subrange  
(class template specialization) [edit]
(class template specialization) [edit]