[range.refinements]

# 25 Ranges library [[ranges]](./#ranges)

## 25.4 Range requirements [[range.req]](range.req#range.refinements)

### 25.4.6 Other range refinements [range.refinements]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1625)

The [output_range](#concept:output_range "25.4.6 Other range refinements [range.refinements]") concept specifies requirements of a[range](range.range#concept:range "25.4.2 Ranges [range.range]") type for which ranges​::​begin returns
a model of [output_iterator](iterator.concept.output#concept:output_iterator "24.3.4.10 Concept output_­iterator [iterator.concept.output]") ([[iterator.concept.output]](iterator.concept.output "24.3.4.10 Concept output_­iterator"))[.](#1.sentence-1)

[input_range](#concept:input_range "25.4.6 Other range refinements [range.refinements]"), [forward_range](#concept:forward_range "25.4.6 Other range refinements [range.refinements]"), [bidirectional_range](#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]"),
and [random_access_range](#concept:random_access_range "25.4.6 Other range refinements [range.refinements]") are defined similarly[.](#1.sentence-2)

[ð](#itemdecl:1)

`template<class R, class T>
  concept [output_range](#concept:output_range "25.4.6 Other range refinements [range.refinements]") =
    [range](range.range#concept:range "25.4.2 Ranges [range.range]")<R> && [output_iterator](iterator.concept.output#concept:output_iterator "24.3.4.10 Concept output_­iterator [iterator.concept.output]")<iterator_t<R>, T>;

template<class T>
  concept [input_range](#concept:input_range "25.4.6 Other range refinements [range.refinements]") =
    [range](range.range#concept:range "25.4.2 Ranges [range.range]")<T> && [input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]")<iterator_t<T>>;

template<class T>
  concept [forward_range](#concept:forward_range "25.4.6 Other range refinements [range.refinements]") =
    [input_range](#concept:input_range "25.4.6 Other range refinements [range.refinements]")<T> && [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]")<iterator_t<T>>;

template<class T>
  concept [bidirectional_range](#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]") =
    [forward_range](#concept:forward_range "25.4.6 Other range refinements [range.refinements]")<T> && [bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]")<iterator_t<T>>;

template<class T>
  concept [random_access_range](#concept:random_access_range "25.4.6 Other range refinements [range.refinements]") =
    [bidirectional_range](#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]")<T> && [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<iterator_t<T>>;
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1654)

[contiguous_range](#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]") additionally requires that
the ranges​::​data customization point object ([[range.prim.data]](range.prim.data "25.3.14 ranges​::​data"))
is usable with the range[.](#2.sentence-1)

[ð](#concept:contiguous_range)

`template<class T>
  concept [contiguous_range](#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]") =
    [random_access_range](#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<T> && [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_­iterator [iterator.concept.contiguous]")<iterator_t<T>> &&
    requires(T& t) {
      { ranges::data(t) } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<add_pointer_t<range_reference_t<T>>>;
    };
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1668)

Given an expression t such that decltype((t)) is T&,T models [contiguous_range](#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]") only ifto_address(​ranges​::​begin(t)) == ranges​::​data(t) is true[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1674)

The [common_range](#concept:common_range "25.4.6 Other range refinements [range.refinements]") concept specifies requirements of
a [range](range.range#concept:range "25.4.2 Ranges [range.range]") type for which ranges​::​begin andranges​::​end return objects of the same type[.](#4.sentence-1)

[*Example [1](#example-1)*:

The standard containers ([[containers]](containers "23 Containers library")) model [common_range](#concept:common_range "25.4.6 Other range refinements [range.refinements]")[.](#4.sentence-2)

â *end example*]

[ð](#concept:common_range)

`template<class T>
  concept [common_range](#concept:common_range "25.4.6 Other range refinements [range.refinements]") =
    [range](range.range#concept:range "25.4.2 Ranges [range.range]")<T> && [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<iterator_t<T>, sentinel_t<T>>;
`

[ð](#itemdecl:4)

`template<class R>
  constexpr bool is-initializer-list = see below;               // exposition only
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1694)

For a type R,*is-initializer-list*<R> is true if and only ifremove_cvref_t<R> is a specialization of initializer_list[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1700)

The [viewable_range](#concept:viewable_range "25.4.6 Other range refinements [range.refinements]") concept specifies the requirements of a[range](range.range#concept:range "25.4.2 Ranges [range.range]") type that can be converted to a view safely[.](#6.sentence-1)

[ð](#concept:viewable_range)

`template<class T>
  concept [viewable_range](#concept:viewable_range "25.4.6 Other range refinements [range.refinements]") =
    [range](range.range#concept:range "25.4.2 Ranges [range.range]")<T> &&
    (([view](range.view#concept:view "25.4.5 Views [range.view]")<remove_cvref_t<T>> && [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<remove_cvref_t<T>, T>) ||
     (![view](range.view#concept:view "25.4.5 Views [range.view]")<remove_cvref_t<T>> &&
      (is_lvalue_reference_v<T> || ([movable](concepts.object#concept:movable "18.6 Object concepts [concepts.object]")<remove_reference_t<T>> && !is-initializer-list<T>))));
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1713)

The [constant_range](#concept:constant_range "25.4.6 Other range refinements [range.refinements]") concept specifies the requirements of a[range](range.range#concept:range "25.4.2 Ranges [range.range]") type whose elements are not modifiable[.](#7.sentence-1)

[ð](#concept:constant_range)

`template<class T>
  concept [constant_range](#concept:constant_range "25.4.6 Other range refinements [range.refinements]") =
    [input_range](#concept:input_range "25.4.6 Other range refinements [range.refinements]")<T> && [constant-iterator](const.iterators.alias#concept:constant-iterator "24.5.3.2 Alias templates [const.iterators.alias]")<iterator_t<T>>;
`

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L1723)

The exposition-only concept [*sized-random-access-range*](#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") specifies the requirements of a [range](range.range#concept:range "25.4.2 Ranges [range.range]") type
that is sized and allows random access to its elements[.](#8.sentence-1)

[ð](#concept:sized-random-access-range)

`template<class T>
  concept [sized-random-access-range](#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") =           // exposition only
    [random_access_range](#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<R> && [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<R>;
`

[*Note [1](#note-1)*:

This concept constrains some parallel algorithm overloads;
see [[algorithms]](algorithms "26 Algorithms library")[.](#sentence-1)

â *end note*]
