Namespaces
Variants
Views
Actions

Experimental library header <experimental/ranges/iterator>

From cppreference.com
< cpp‎ | header‎ | experimental
 
 
Standard library headers
Language support
Concepts
<concepts> (C++20)
Diagnostics
<system_error> (C++11)

Memory management
<memory_resource> (C++17)  
Metaprogramming
<type_traits> (C++11)
<ratio> (C++11)
General utilities
<utility>
<tuple> (C++11)
<optional> (C++17)
<variant> (C++17)
<any> (C++17)
<debugging> (C++26)
<expected> (C++23)
<bitset>
<charconv> (C++17)
<format> (C++20)
<bit> (C++20)

Strings
<cuchar> (C++11)

Containers
<flat_set> (C++23)
<span> (C++20)
<mdspan> (C++23)

Iterators
<iterator>
Ranges
<ranges> (C++20)
<generator> (C++23)
Algorithms
Numerics
<cfenv> (C++11)
<complex>
<cmath>
<linalg> (C++26)
<numbers> (C++20)

Time
<chrono> (C++11)
Localization
<codecvt> (C++11/17/26*)
<text_encoding> (C++26)
Input/output
<filesystem> (C++17)
<cstdio>
<cinttypes> (C++11)
<strstream> (C++98*)
Regular expressions
<regex> (C++11)
Concurrency support
<stop_token> (C++20)
<thread> (C++11)
<atomic> (C++11)
<rcu> (C++26)
<stdatomic.h> (C++23)
<mutex> (C++11)
<shared_mutex> (C++14)

<condition_variable> (C++11)  
<semaphore> (C++20)
<latch> (C++20)

<barrier> (C++20)
<future> (C++11)
<hazard_pointer> (C++26)

C compatibility
<cstdbool> (C++11/17/20*)  
<ccomplex> (C++11/17/20*)
<ctgmath> (C++11/17/20*)

<cstdalign> (C++11/17/20*)

<ciso646> (until C++20)

 
Experimental library headers
Execution P2300
<experimental/execution>
Filesystem TS
<experimental/filesystem>
Parallelism TS (v1, v2)
experimental/algorithm
experimental/execution_policy
experimental/exception_list
experimental/numeric
<experimental/simd>
experimental/task_block
Library Fundamentals TS (v1, v2, v3)
experimental/algorithm
<experimental/any>
experimental/array
experimental/chrono
experimental/deque
experimental/forward_list
<experimental/functional>
experimental/future
experimental/iterator
experimental/list
experimental/map
experimental/memory
<experimental/memory_resource>
experimental/numeric
<experimental/optional>
experimental/propagate_const
experimental/random
experimental/ratio
experimental/regex
experimental/scope
experimental/set
experimental/source_location
experimental/string
<experimental/string_view>
experimental/system_error
experimental/tuple
experimental/type_traits
experimental/unordered_map
experimental/unordered_set
experimental/utility
experimental/vector

Concurrency TS
experimental/atomic
experimental/barrier
experimental/future
experimental/latch
Ranges TS
Coroutines TS
experimental/coroutine
Networking TS
experimental/buffer
experimental/executor
experimental/internet
experimental/io_context
<experimental/net>
experimental/netfwd
experimental/socket
experimental/timer
Reflection TS
<experimental/reflect>
 

This header is part of the ranges library.

Contents

[edit] Iterator-related concepts

Defined in namespace std::experimental::ranges

[edit] Iterator concepts

specifies that a type is readable by applying operator *
(concept) [edit]
specifies that a value can be written to an iterator's referenced object
(concept) [edit]
specifies that a Semiregular type can be incremented with pre- and post-increment operators
(concept) [edit]
specifies that the increment operation on a WeaklyIncrementable type is equality-preserving and that the type is EqualityComparable
(concept) [edit]
specifies that objects of a type can be incremented and dereferenced
(concept) [edit]
specifies that objects of a type is a sentinel for an Iterator type
(concept) [edit]
specifies that the - operator can be applied to an iterator and a sentinel to calculate their difference in constant time
(concept) [edit]
specifies that a type is an input iterator, that is, its referenced values can be read and it can be both pre- and post-incremented
(concept) [edit]
specifies that a type is an output iterator for a given value type, that is, values of that type can be written to it and it can be both pre- and post-incremented
(concept) [edit]
specifies that an InputIterator is a forward iterator, supporting equality comparison and multi-pass
(concept) [edit]
specifies that a ForwardIterator is a bidirectional iterator, supporting movement backwards
(concept) [edit]
specifies that a BidirectionalIterator is a random-access iterator, supporting advancement in constant time and subscripting
(concept) [edit]

[edit] Indirect callable concepts

specifies that a callable type can be invoked with the result of dereferencing a Readable type
(concept) [edit]
specifies that a callable object, when invoked with the result of dereferencing a Readable type, satisfies Predicate
(concept) [edit]
specifies that a callable object, when invoked with the result of dereferencing some Readable types, satisfies Relation
(concept) [edit]
specifies that a callable object, when invoked with the result of dereferencing some Readable types, satisfies StrictWeakOrder
(concept) [edit]

[edit] Common algorithm requirements

specifies that values may be moved from a Readable type to a Writable type
(concept) [edit]
specifies that values may be moved from a Readable type to a Writable type and that the move may be performed via an intermediate object
(concept) [edit]
specifies that values may be copied from a Readable type to a Writable type
(concept) [edit]
specifies that values may be copied from a Readable type to a Writable type and that the copy may be performed via an intermediate object
(concept) [edit]
specifies that the values referenced by two Readable types can be swapped
(concept) [edit]
specifies that the values referenced by two Readable types can be compared
(concept) [edit]
specifies the common requirements of algorithms that reorder elements in place
(concept) [edit]
specifies the requirements of algorithms that merge sorted sequences into an output sequence by copying elements
(concept) [edit]
specifies the common requirements of algorithms that permute sequences into ordered sequences
(concept) [edit]

[edit] Concept utilities

compute the result of invoking a callable object on the result of dereferencing some set of Readable types
(class template) [edit]
helper template for specifying the constraints on algorithms that accept projections
(class template) [edit]

[edit] Iterator primitives

[edit] Iterator utilities

Defined in namespace std::experimental::ranges
casts the result of dereferencing an object to its associated rvalue reference type
(customization point object)[edit]
swap the values referenced by two dereferenceable objects
(customization point object)[edit]

[edit] Iterator traits

Defined in namespace std::experimental::ranges
obtains the difference type of a WeaklyIncrementable type
(class template) [edit]
obtains the value type of a Readable type
(class template) [edit]
obtains the iterator category of an input iterator type
(class template) [edit]
compatibility traits class that collects an iterator’s associated types
(alias template)[edit]
obtains a dereferenceable object's associated reference types
(alias template)[edit]

[edit] Iterator category tags

Defined in namespace std::experimental::ranges
empty class types used to indicate iterator categories
(class) [edit]

[edit] std::iterator_traits specializations

Defined in namespace std
specializes std::iterator_traits for ranges TS iterators
(class template specialization) [edit]

[edit] Iterator operations

Defined in namespace std::experimental::ranges
advances an iterator by given distance
(function template) [edit]
returns the distance between an iterator and a sentinel, or between the beginning and the end of a range
(function template) [edit]
increment an iterator
(function template) [edit]
decrement an iterator
(function template) [edit]

[edit] Iterator adaptors

Defined in namespace std::experimental::ranges
iterator adaptor for reverse-order traversal
(class template) [edit]
iterator adaptor for insertion at the end of a container
(class template) [edit]
iterator adaptor for insertion at the front of a container
(class template) [edit]
iterator adaptor for insertion into a container
(class template) [edit]
iterator adaptor which dereferences to an rvalue reference
(class template) [edit]
sentinel adaptor for use with move_iterator
(class template) [edit]
adapt an iterator-sentinel pair into a common iterator type for use with legacy algorithms
(class template) [edit]
iterator adaptor that keeps track of its distance from its starting position
(class template) [edit]
empty sentinel type for use with iterator types that know the bound of their range
(class) [edit]
wrapper for a possibly dangling iterator
(class template) [edit]
alias template that wraps the iterator type of an rvalue range with dangling
(alias template)[edit]
sentinel type used with any iterator to denote an infinite range
(class) [edit]

[edit] Stream iterators

Defined in namespace std::experimental::ranges
input iterator that reads from std::basic_istream
(class template) [edit]
output iterator that writes to std::basic_ostream
(class template) [edit]
input iterator that reads from std::basic_streambuf
(class template) [edit]
output iterator that writes to std::basic_streambuf
(class template) [edit]

[edit] Synopsis

namespace std { namespace experimental { namespace ranges { inline namespace v1 {
 
template <class T> concept bool /* dereferenceable */ // exposition only
  = requires(T& t) { {*t} -> auto&&; };
 
namespace {
  constexpr /* unspecified */ iter_move = /* unspecified */;
  constexpr /* unspecified */ iter_swap = /* unspecified */;
}
 
template <class> struct difference_type;
template <class T> using difference_type_t
  = typename difference_type<T>::type;
 
template <class> struct value_type;
template <class T> using value_type_t
  = typename value_type<T>::type;
 
template <class> struct iterator_category;
template <class T> using iterator_category_t
  = typename iterator_category<T>::type;
 
template </* dereferenceable */ T> using reference_t
  = decltype(*declval<T&>());
 
template </* dereferenceable */ T>
    requires /* see definition */ using rvalue_reference_t
  = decltype(ranges::iter_move(declval<T&>()));
 
template <class In>
concept bool Readable = /* see definition */;
 
template <class Out, class T>
concept bool Writable = /* see definition */;
 
template <class I>
concept bool WeaklyIncrementable = /* see definition */;
 
template <class I>
concept bool Incrementable = /* see definition */;
 
template <class I>
concept bool Iterator = /* see definition */;
 
template <class S, class I>
concept bool Sentinel = /* see definition */;
 
template <class S, class I>
  constexpr bool disable_sized_sentinel = false;
 
template <class S, class I>
concept bool SizedSentinel = /* see definition */;
 
template <class I>
concept bool InputIterator = /* see definition */;
 
template <class I>
concept bool OutputIterator = /* see definition */;
 
template <class I>
concept bool ForwardIterator = /* see definition */;
 
template <class I>
concept bool BidirectionalIterator = /* see definition */;
 
template <class I>
concept bool RandomAccessIterator = /* see definition */;
 
template <class F, class I>
concept bool IndirectUnaryInvocable = /* see definition */;
 
template <class F, class I>
concept bool IndirectRegularUnaryInvocable = /* see definition */;
 
template <class F, class I>
concept bool IndirectUnaryPredicate = /* see definition */;
 
template <class F, class I1, class I2 = I1>
concept bool IndirectRelation = /* see definition */;
 
template <class F, class I1, class I2 = I1>
concept bool IndirectStrictWeakOrder = /* see definition */;
 
template <class> struct indirect_result_of;
 
template <class F, class... Is>
  requires Invocable<F, reference_t<Is>...>
struct indirect_result_of<F(Is...)>;
 
template <class F>
using indirect_result_of_t
  = typename indirect_result_of<F>::type;
 
template <Readable I, IndirectRegularUnaryInvocable<I> Proj>
struct projected;
 
template <WeaklyIncrementable I, class Proj>
struct difference_type<projected<I, Proj>>;
 
template <class In, class Out>
concept bool IndirectlyMovable = /* see definition */;
 
template <class In, class Out>
concept bool IndirectlyMovableStorable = /* see definition */;
 
template <class In, class Out>
concept bool IndirectlyCopyable = /* see definition */;
 
template <class In, class Out>
concept bool IndirectlyCopyableStorable = /* see definition */;
 
template <class I1, class I2 = I1>
concept bool IndirectlySwappable = /* see definition */;
 
template <class I1, class I2, class R = equal_to<>, class P1 = identity,
    class P2 = identity>
concept bool IndirectlyComparable = /* see definition */;
 
template <class I>
concept bool Permutable = /* see definition */;
 
template <class I1, class I2, class Out,
    class R = less<>, class P1 = identity, class P2 = identity>
concept bool Mergeable = /* see definition */;
 
template <class I, class R = less<>, class P = identity>
concept bool Sortable = /* see definition */;
 
template <class Iterator> using iterator_traits = /* see definition */;
 
template <Readable T> using iter_common_reference_t
  = common_reference_t<reference_t<T>, value_type_t<T>&>;
 
struct output_iterator_tag { };
struct input_iterator_tag { };
struct forward_iterator_tag : input_iterator_tag { };
struct bidirectional_iterator_tag : forward_iterator_tag { };
struct random_access_iterator_tag : bidirectional_iterator_tag { };
 
namespace {
  constexpr /* unspecified */ advance = /* unspecified */;
  constexpr /* unspecified */ distance = /* unspecified */;
  constexpr /* unspecified */ next = /* unspecified */;
  constexpr /* unspecified */ prev = /* unspecified */;
}
 
template <BidirectionalIterator I> class reverse_iterator;
 
template <class I1, class I2>
    requires EqualityComparableWith<I1, I2>
  constexpr bool operator==(
    const reverse_iterator<I1>& x,
    const reverse_iterator<I2>& y);
template <class I1, class I2>
    requires EqualityComparableWith<I1, I2>
  constexpr bool operator!=(
    const reverse_iterator<I1>& x,
    const reverse_iterator<I2>& y);
template <class I1, class I2>
    requires StrictTotallyOrderedWith<I1, I2>
  constexpr bool operator<(
    const reverse_iterator<I1>& x,
    const reverse_iterator<I2>& y);
template <class I1, class I2>
    requires StrictTotallyOrderedWith<I1, I2>
  constexpr bool operator>(
    const reverse_iterator<I1>& x,
    const reverse_iterator<I2>& y);
template <class I1, class I2>
    requires StrictTotallyOrderedWith<I1, I2>
  constexpr bool operator>=(
    const reverse_iterator<I1>& x,
    const reverse_iterator<I2>& y);
template <class I1, class I2>
    requires StrictTotallyOrderedWith<I1, I2>
  constexpr bool operator<=(
    const reverse_iterator<I1>& x,
    const reverse_iterator<I2>& y);
 
template <class I1, class I2>
    requires SizedSentinel<I1, I2>
  constexpr difference_type_t<I2> operator-(
    const reverse_iterator<I1>& x,
    const reverse_iterator<I2>& y);
template <RandomAccessIterator I>
  constexpr reverse_iterator<I> operator+(
    difference_type_t<I> n,
    const reverse_iterator<I>& x);
 
template <BidirectionalIterator I>
constexpr reverse_iterator<I> make_reverse_iterator(I i);
 
template <class Container> class back_insert_iterator;
template <class Container>
  back_insert_iterator<Container> back_inserter(Container& x);
 
template <class Container> class front_insert_iterator;
template <class Container>
  front_insert_iterator<Container> front_inserter(Container& x);
 
template <class Container> class insert_iterator;
template <class Container>
  insert_iterator<Container> inserter(Container& x, iterator_t<Container> i);
 
template <InputIterator I> class move_iterator;
 
template <class I1, class I2>
    requires EqualityComparableWith<I1, I2>
  constexpr bool operator==(
    const move_iterator<I1>& x, const move_iterator<I2>& y);
template <class I1, class I2>
    requires EqualityComparableWith<I1, I2>
  constexpr bool operator!=(
    const move_iterator<I1>& x, const move_iterator<I2>& y);
template <class I1, class I2>
    requires StrictTotallyOrderedWith<I1, I2>
  constexpr bool operator<(
    const move_iterator<I1>& x, const move_iterator<I2>& y);
template <class I1, class I2>
    requires StrictTotallyOrderedWith<I1, I2>
  constexpr bool operator<=(
    const move_iterator<I1>& x, const move_iterator<I2>& y);
template <class I1, class I2>
    requires StrictTotallyOrderedWith<I1, I2>
  constexpr bool operator>(
    const move_iterator<I1>& x, const move_iterator<I2>& y);
template <class I1, class I2>
    requires StrictTotallyOrderedWith<I1, I2>
  constexpr bool operator>=(
    const move_iterator<I1>& x, const move_iterator<I2>& y);
 
template <class I1, class I2>
    requires SizedSentinel<I1, I2>
  constexpr difference_type_t<I2> operator-(
    const move_iterator<I1>& x,
    const move_iterator<I2>& y);
template <RandomAccessIterator I>
  constexpr move_iterator<I> operator+(
    difference_type_t<I> n,
    const move_iterator<I>& x);
 
template <InputIterator I>
  constexpr move_iterator<I> make_move_iterator(I i);
 
template <Semiregular S> class move_sentinel;
 
template <class I, Sentinel<I> S>
  constexpr bool operator==(
    const move_iterator<I>& i, const move_sentinel<S>& s);
template <class I, Sentinel<I> S>
  constexpr bool operator==(
    const move_sentinel<S>& s, const move_iterator<I>& i);
template <class I, Sentinel<I> S>
  constexpr bool operator!=(
    const move_iterator<I>& i, const move_sentinel<S>& s);
template <class I, Sentinel<I> S>
  constexpr bool operator!=(
    const move_sentinel<S>& s, const move_iterator<I>& i);
 
template <class I, SizedSentinel<I> S>
  constexpr difference_type_t<I> operator-(
    const move_sentinel<S>& s, const move_iterator<I>& i);
template <class I, SizedSentinel<I> S>
  constexpr difference_type_t<I> operator-(
    const move_iterator<I>& i, const move_sentinel<S>& s);
 
template <Semiregular S>
  constexpr move_sentinel<S> make_move_sentinel(S s);
 
template <Iterator I, Sentinel<I> S>
  requires !Same<I, S>
class common_iterator;
 
template <Readable I, class S>
struct value_type<common_iterator<I, S>>;
 
template <InputIterator I, class S>
struct iterator_category<common_iterator<I, S>>;
 
template <ForwardIterator I, class S>
struct iterator_category<common_iterator<I, S>>;
 
template <class I1, class I2, Sentinel<I2> S1, Sentinel<I1> S2>
bool operator==(
  const common_iterator<I1, S1>& x, const common_iterator<I2, S2>& y);
template <class I1, class I2, Sentinel<I2> S1, Sentinel<I1> S2>
  requires EqualityComparableWith<I1, I2>
bool operator==(
  const common_iterator<I1, S1>& x, const common_iterator<I2, S2>& y);
template <class I1, class I2, Sentinel<I2> S1, Sentinel<I1> S2>
bool operator!=(
  const common_iterator<I1, S1>& x, const common_iterator<I2, S2>& y);
 
template <class I2, SizedSentinel<I2> I1, SizedSentinel<I2> S1, SizedSentinel<I1> S2>
difference_type_t<I2> operator-(
  const common_iterator<I1, S1>& x, const common_iterator<I2, S2>& y);
 
class default_sentinel;
 
template <Iterator I> class counted_iterator;
 
template <class I1, class I2>
    requires Common<I1, I2>
  constexpr bool operator==(
    const counted_iterator<I1>& x, const counted_iterator<I2>& y);
constexpr bool operator==(
  const counted_iterator<auto>& x, default_sentinel);
constexpr bool operator==(
  default_sentinel, const counted_iterator<auto>& x);
template <class I1, class I2>
    requires Common<I1, I2>
  constexpr bool operator!=(
    const counted_iterator<I1>& x, const counted_iterator<I2>& y);
constexpr bool operator!=(
  const counted_iterator<auto>& x, default_sentinel y);
constexpr bool operator!=(
  default_sentinel x, const counted_iterator<auto>& y);
template <class I1, class I2>
    requires Common<I1, I2>
  constexpr bool operator<(
    const counted_iterator<I1>& x, const counted_iterator<I2>& y);
template <class I1, class I2>
    requires Common<I1, I2>
  constexpr bool operator<=(
    const counted_iterator<I1>& x, const counted_iterator<I2>& y);
template <class I1, class I2>
    requires Common<I1, I2>
  constexpr bool operator>(
    const counted_iterator<I1>& x, const counted_iterator<I2>& y);
template <class I1, class I2>
    requires Common<I1, I2>
  constexpr bool operator>=(
    const counted_iterator<I1>& x, const counted_iterator<I2>& y);
 
template <class I1, class I2>
    requires Common<I1, I2>
  constexpr difference_type_t<I2> operator-(
    const counted_iterator<I1>& x, const counted_iterator<I2>& y);
template <class I>
  constexpr difference_type_t<I> operator-(
    const counted_iterator<I>& x, default_sentinel y);
template <class I>
  constexpr difference_type_t<I> operator-(
    default_sentinel x, const counted_iterator<I>& y);
template <RandomAccessIterator I>
  constexpr counted_iterator<I>
    operator+(difference_type_t<I> n, const counted_iterator<I>& x);
 
template <Iterator I>
  constexpr counted_iterator<I> make_counted_iterator(I i, difference_type_t<I> n);
 
class unreachable;
template <Iterator I>
  constexpr bool operator==(const I&, unreachable) noexcept;
template <Iterator I>
  constexpr bool operator==(unreachable, const I&) noexcept;
template <Iterator I>
  constexpr bool operator!=(const I&, unreachable) noexcept;
template <Iterator I>
  constexpr bool operator!=(unreachable, const I&) noexcept;
 
template <class T> class dangling;
 
template <class T, class CharT = char, class Traits = char_traits<CharT>,
    class Distance = ptrdiff_t>
  class istream_iterator;
 
template <class T, class CharT, class Traits, class Distance>
  bool operator==(const istream_iterator<T, CharT, Traits, Distance>& x,
    const istream_iterator<T, CharT, Traits, Distance>& y);
template <class T, class CharT, class Traits, class Distance>
  bool operator==(default_sentinel x,
    const istream_iterator<T, CharT, Traits, Distance>& y);
template <class T, class CharT, class Traits, class Distance>
  bool operator==(const istream_iterator<T, CharT, Traits, Distance>& x,
    default_sentinel y);
template <class T, class CharT, class Traits, class Distance>
  bool operator!=(const istream_iterator<T, CharT, Traits, Distance>& x,
    const istream_iterator<T, CharT, Traits, Distance>& y);
template <class T, class CharT, class Traits, class Distance>
  bool operator!=(default_sentinel x,
    const istream_iterator<T, CharT, Traits, Distance>& y);
template <class T, class CharT, class Traits, class Distance>
  bool operator!=(const istream_iterator<T, CharT, Traits, Distance>& x,
    default_sentinel y);
 
template <class T, class CharT = char, class Traits = char_traits<CharT>>
  class ostream_iterator;
 
template <class CharT, class Traits = char_traits<CharT> >
  class istreambuf_iterator;
 
template <class CharT, class Traits>
  bool operator==(const istreambuf_iterator<CharT, Traits>& a,
    const istreambuf_iterator<CharT, Traits>& b);
template <class CharT, class Traits>
  bool operator==(default_sentinel a,
    const istreambuf_iterator<CharT, Traits>& b);
template <class CharT, class Traits>
  bool operator==(const istreambuf_iterator<CharT, Traits>& a,
    default_sentinel b);
template <class CharT, class Traits>
  bool operator!=(const istreambuf_iterator<CharT, Traits>& a,
    const istreambuf_iterator<CharT, Traits>& b);
template <class CharT, class Traits>
  bool operator!=(default_sentinel a,
    const istreambuf_iterator<CharT, Traits>& b);
template <class CharT, class Traits>
  bool operator!=(const istreambuf_iterator<CharT, Traits>& a,
    default_sentinel b);
 
template <class CharT, class Traits = char_traits<CharT> >
  class ostreambuf_iterator;
 
}}}}
 
namespace std {
  template <experimental::ranges::Iterator Out>
    struct iterator_traits<Out>;
  template <experimental::ranges::InputIterator In>
    struct iterator_traits<In>;
  template <experimental::ranges::InputIterator In>
      requires experimental::ranges::Sentinel<In, In>
    struct iterator_traits;
}