---
name: "std::ranges::subrange"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::ranges::subrange/3cxx"
---

# std::ranges::subrange(3cxx)

The ranges::subrange class template.

## NAME

std::ranges::subrange\< \_It, \_Sent, \_Kind \> - The ranges::subrange class template.

## SYNOPSIS

`#include <ranges>`

Inherits **std::ranges::view\_interface\< \_Derived \>**.

### Public Member Functions

constexpr **subrange** (\_\_detail::\_\_convertible\_to\_non\_slicing\< \_It \> **auto** \_\_i, \_Sent **\_\_s**) noexcept(is\_nothrow\_constructible\_v\< \_It, **decltype**(\_\_i)\> &&is\_nothrow\_constructible\_v\< \_Sent, \_Sent & \>)\
 constexpr **subrange** (\_\_detail::\_\_convertible\_to\_non\_slicing\< \_It \> **auto** \_\_i, \_Sent **\_\_s**, \_\_size\_type \_\_n) noexcept(is\_nothrow\_constructible\_v\< \_It, **decltype**(\_\_i)\> &&is\_nothrow\_constructible\_v\< \_Sent, \_Sent & \>)\
 template\<\_\_detail::\_\_different\_from\< **subrange** \> \_Rng\> \
 requires borrowed\_range\<**\_Rng**\> && \_\_detail::\_\_convertible\_to\_non\_slicing\<iterator\_t\<**\_Rng**\>, \_It\> && convertible\_to\<sentinel\_t\<**\_Rng**\>, \_Sent\>constexpr **subrange** (**\_Rng** &&\_\_r) noexcept(noexcept(**subrange**(\_\_r, ranges::size(\_\_r)))) \_S\_store\_size &&sized\_range\< **\_Rng** \>"\
 template\<\_\_detail::\_\_different\_from\< **subrange** \> \_Rng\> \
 requires borrowed\_range\<**\_Rng**\> && \_\_detail::\_\_convertible\_to\_non\_slicing\<iterator\_t\<**\_Rng**\>, \_It\> && convertible\_to\<sentinel\_t\<**\_Rng**\>, \_Sent\> (!\_S\_store\_size)constexpr **subrange** (**\_Rng** &&\_\_r) noexcept(noexcept(**subrange**(ranges::begin(\_\_r), ranges::end(\_\_r))))"\
 template\<borrowed\_range \_Rng\> \
 requires \_\_detail::\_\_convertible\_to\_non\_slicing\<iterator\_t\<**\_Rng**\>, \_It\> && convertible\_to\<sentinel\_t\<**\_Rng**\>, \_Sent\> (**\_Kind** == subrange\_kind::sized)constexpr **subrange** (**\_Rng** &&\_\_r, \_\_size\_type \_\_n) noexcept(noexcept(**subrange**(ranges::begin(\_\_r), ranges::end(\_\_r), \_\_n)))"\
 constexpr **subrange** & **advance** (iter\_difference\_t\< \_It \> \_\_n)\
 constexpr **decltype**(**auto**) **back** ()\
 constexpr **decltype**(**auto**) **back** () const\
 constexpr \_It **begin** ()\
 constexpr \_It **begin** () const\
 constexpr **auto** **data** () const noexcept(noexcept(ranges::begin(\_M\_derived())))\
 constexpr **auto** **data** () noexcept(noexcept(ranges::begin(\_M\_derived())))\
 constexpr bool **empty** () const\
 constexpr bool **empty** () noexcept(noexcept(\_S\_empty(\_M\_derived())))\
 constexpr \_Sent **end** () const\
 constexpr **decltype**(**auto**) **front** ()\
 constexpr **decltype**(**auto**) **front** () const\
 constexpr **subrange** **next** (iter\_difference\_t\< \_It \> \_\_n=1) &&\
 constexpr **subrange** **next** (iter\_difference\_t\< \_It \> \_\_n=1) const &\
 template\<\_\_detail::\_\_different\_from\< **subrange** \> \_PairLike\> \
 requires \_\_detail::\_\_pair\_like\_convertible\_from\<**\_PairLike**, const \_It&, const \_Sent&\>constexpr **operator \_PairLike** () const"\
 constexpr **operator bool** () const noexcept(noexcept(ranges::empty(\_M\_derived())))\
 constexpr **operator bool** () noexcept(noexcept(ranges::empty(\_M\_derived())))\
 template\<random\_access\_range \_Range = \_Derived\> constexpr **decltype**(**auto**) **operator\[\]** (**range\_difference\_t**\< \_Range \> \_\_n)\
 template\<random\_access\_range \_Range = const \_Derived\> constexpr **decltype**(**auto**) **operator\[\]** (**range\_difference\_t**\< \_Range \> \_\_n) const\
 constexpr **subrange** **prev** (iter\_difference\_t\< \_It \> \_\_n=1) const\
 constexpr \_\_size\_type **size** () const\
 constexpr **auto** **size** () noexcept(noexcept(\_S\_size(\_M\_derived())))\

### Friends

**struct** **views::\_Drop**\

## Detailed Description

### template\<input\_or\_output\_iterator \_It, sentinel\_for\< \_It \> \_Sent = \_It, subrange\_kind \_Kind = sized\_sentinel\_for\<\_Sent, \_It\> ? subrange\_kind::sized : subrange\_kind::unsized\>

requires (**\_Kind** == subrange\_kind::sized \|\| !sized\_sentinel\_for\<\_Sent, \_It\>)\
 class std::ranges::subrange\< \_It, \_Sent, \_Kind \>"The ranges::subrange class template.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
