"cpp/ranges/subrange/next")  
[ subrange::prev  ](/w/cpp/ranges/subrange/prev "cpp/ranges/subrange/prev")  
[ Deduction guides ](/w/cpp/ranges/subrange/deduction_guides
"cpp/ranges/subrange/deduction guides")  
[ Non-member functions ](/w/cpp/ranges/subrange#Non-member_functions
"cpp/ranges/subrange")  
[ get  (std::ranges::subrange)  ](/w/cpp/ranges/subrange/get
"cpp/ranges/subrange/get")  
[ Helper types ](/w/cpp/ranges/subrange#Helper_types "cpp/ranges/subrange")  
[ subrange_kind  ](/w/cpp/ranges/subrange_kind "cpp/ranges/subrange kind")  
[ tuple_size  <std::ranges::subrange> ](/w/cpp/ranges/subrange/tuple_size
"cpp/ranges/subrange/tuple size")  
[ tuple_element  <std::ranges::subrange>
](/w/cpp/ranges/subrange/tuple_element "cpp/ranges/subrange/tuple element")  
  
[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/subrange/navbar_content&action=edit)

Defined in header ` [ <ranges> ](/w/cpp/header/ranges "cpp/header/ranges") ` |  |   
---|---|---  
template  <  
[ std::  input_or_output_iterator
](http://en.cppreference.com/w/cpp/iterator/input_or_output_iterator) I,  
[ std::  sentinel_for
](http://en.cppreference.com/w/cpp/iterator/sentinel_for) < I  > S  =  I,  
[ ranges::  subrange_kind
](http://en.cppreference.com/w/cpp/ranges/subrange_kind) K  =  [ std::
sized_sentinel_for
](http://en.cppreference.com/w/cpp/iterator/sized_sentinel_for) < S, I  > ?  
ranges  ::  subrange_kind  ::  sized  :  ranges  ::  subrange_kind  ::
unsized  
>  
requires  (  K  ==  ranges  ::  subrange_kind  ::  sized  ||  !  [ std::
sized_sentinel_for
](http://en.cppreference.com/w/cpp/iterator/sized_sentinel_for) < S, I  > )  
class  subrange  :  public  [ ranges::  view_interface  ](http://en.cppreference.com/w/cpp/ranges/view_interface) < subrange  < I, S, K  >> |  |  (since C++20)   
|  |   
  
The ` subrange ` class template combines together an iterator and a sentinel
into a single [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view") .

Additionally, the subrange is a [ ` sized_range ` ](/w/cpp/ranges/sized_range
"cpp/ranges/sized range") whenever the final template parameter is
subrange_kind​  ::  ​sized  (which happens when  [ std::  sized_sentinel_for
](http://en.cppreference.com/w/cpp/iterator/sized_sentinel_for) < S, I  > is
satisfied or when size is passed explicitly as a constructor argument). The
size record is needed to be stored if and only if  [ std::  sized_sentinel_for
](http://en.cppreference.com/w/cpp/iterator/sized_sentinel_for) < S, I  > is
false  and ` K ` is  subrange_kind  ::  sized  .

##  Contents

  * 1  Member functions 
    * 1.1  Observers 
    * 1.2  Iterator operations 
    * 1.3  Inherited from  std::ranges::view_interface 
  * 2  Deduction guides 
  * 3  Non-member functions 
  * 4  Helper types 
  * 5  Helper templates 
  * 6  Example 
  * 7  See also 

  
---  
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/subrange&action=edit&section=1 "Edit
section: Member functions") ]  Member functions

[ (constructor)  ](/w/cpp/ranges/subrange/subrange "cpp/ranges/subrange/subrange") (C++20)  |  creates a new ` subrange `   
(public member function)  
---|---  
[ operator PairLike  ](/w/cpp/ranges/subrange/operator_PairLike "cpp/ranges/subrange/operator PairLike") (C++20)  |  converts the ` subrange ` to a [ ` _pair-like_ ` ](/w/cpp/utility/tuple/tuple-like "cpp/utility/tuple/tuple-like") type   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/subrange/dsc_operator_PairLike&action=edit)  
  
#####  Observers  
  
[ begin  ](/w/cpp/ranges/subrange/begin "cpp/ranges/subrange/begin") (C++20)  |  obtains the iterator   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/subrange/dsc_begin&action=edit)  
[ end  ](/w/cpp/ranges/subrange/end "cpp/ranges/subrange/end") (C++20)  |  obtains the sentinel   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/ind