Range concepts (details)¶
Table of Contents
Range¶
-
template<typename
Rng>
conceptRange¶ - Refines the
template <typename T> Semiregularconcept. Rngprovides methodsbegin,end,cbeginandcend.
Notation
Valid Expressions
rng()returns an instance ofRng.crng()returns an instance ofconst Rng.rng_cpy(rng)returns an instance ofRng.rng_cpy(crng)returns an instance ofRng.rng_cpy(move(rng))returns an instance ofRng.rng_cpy = rngreturns an instance ofRng&.rng_cpy = crngreturns an instance ofRng&.rng_cpy = move(rng)returns an instance ofRng&.rng.begin()is valid and return type is implementation defined.rng.end()is valid and return type is implementation defined.crng.cbegin()is valid and return type is implementation defined.crng.cend()is valid and return type is implementation defined.
Possible implementation
template<typename R, Rng = remove_cvref<R>> concept Range = Semiregular<Rng> && requires(Rng rng, const Rng crng) { { rng.begin() } -> /* implementation defined */; { rng.end() } -> /* implementation defined */; { crng.cbegin() } -> /* implementation defined */; { crng.cend() } -> /* implementation defined */; };
- Refines the
SizedRange¶
-
template<typename
SRng>
conceptSizedRange¶ - Refines the
template <typename SRng> Rangeconcept. SRng::iterator_typeprovides methodsize.
Notation
-
using
difference_type= iterator_type::difference_type¶
Valid Expressions
csrng.size()returns an instance ofdifference_type.
Possible implementation
template <typename Rng> inline constexpr bool disable_sized_range = /* implementation defined */; template<typename R, SRng = remove_cvref<R>> concept SizedRange = Range<SRng> && !disable_sized_range<SRng> && requires(const SRng csrng) { { csrng.size() } -> Rng::iterator_type::difference_type; };
- Refines the
InputRange¶
-
template<typename
IRng>
conceptInputRange¶ - Refines the
template <typename Rng> Rangeconcept. IRng::iterator_typemodels thetemplate <typename I> InputIteratorconcept.IRng::iterator_typeprovidesoperator++(pre- and post-fix) andoperator*(dereference read-only).
Notation
-
const iterator_type
cit¶
Valid Expressions
++itreturns an instance ofiterator_type&.it++is not requires to be equality preserving.*citreturn-type can be deduced byauto&&.
Possible implementation
template<typename R, Rng = remove_cvref<R>> concept InputRange = Range<Rng> && requires { typename Rng::iterator_type; } && InputIterator<Rng::iterator_type>;
- Refines the
OutputRange¶
-
template<typename
ORng, typenameT>
conceptOutputRange¶ - Refines the
template <typename Rng> Rangeconcept. ORng::iterator_typemodels thetemplate <typename I, typename T> OutputIteratorconcept.ORng::iterator_typeprovidesoperator++(pre- and post-fix) andoperator*(dereference writable).
Notation
-
using
reference= iterator_type::reference¶
-
const iterator_type
co¶
Valid Expressions
++oreturns an instance ofFwdRng&.o++is not requires to be equality preserving.*coreturn-type can be deduced byauto&&.*o++ = forward<T>(t)is not requires to be equality preserving.*o = forward<T>(t)is not requires to be equality preserving.*forward<iterator_type>(o) = forward<T>(t)is not requires to be equality preserving.const_cast<const reference&&>(*o) = forward<T>(t)is not requires to be equality preserving.const_cast<const reference&&>(*forward<iterator_type>(o)) = forward<T>(t)is not requires to be equality preserving.
Possible implementation
template<typename R, typename T, Rng = remove_cvref<R>> concept OutputRange = Range<Rng> && requires { typename Rng::iterator_type; } && OuputIterator<Rng::iterator_type, T>;
- Refines the
ForwardRange¶
-
template<typename
FwdRng>
conceptForwardRange¶ - Refines the
template <typename IRng> InputRangeconcept. FwdRng::iterator_typemodels thetemplate <typename I> ForwardIteratorconcept.FwdRngis consistant withvalue_typefromiterator_type.FwdRng::iterator_typeprovides methodsoperator++.
Notation
-
const iterator_type
lhs¶
-
const iterator_type
rhs¶
Valid Expressions
lhs == rhsreturn-type modelstemplate<typename B> Boolean.lhs != rhsreturn-type modelstemplate<typename B> Boolean.rhs == lhsreturn-type modelstemplate<typename B> Boolean.rhs != lhsreturn-type modelstemplate<typename B> Boolean.it++returns an instance ofiterator_type&&
Possible implementation
template<typename R, FwdRng = remove_cvref<R>> concept ForwardRange = InputRange<FwdRng> && ForwardIterator<FwdRng::iterator_type> && requires { typename FwdRng::value_type; } && Same<FwdRng::value_type, FwdRng::iterator_type::value_type>;
- Refines the
BidirectionalRange¶
-
template<typename
BidirRng>
conceptBidirectionalRange¶ - Refines the
template <typename Rng> ForwardRangeconcept. BidirRng::iterator_typemodels thetemplate <typename I> BidirectionalIteratorconcept.BidirRng::iterator_typeprovides methodsoperator--(postfix and prefix).BidirRngprovides methodsrbegin,rend,crbeginandcrend.
Notation
Valid Expressions
--itreturns an instance ofiterator_type&.it--returns an instance ofiterator_type&&.bidirrng.rbegin()is valid and return type is implementation defined.bidirrng.rend()is valid and return type is implementation defined.cbidirrng.crbegin()is valid and return type is implementation defined.cbidirrng.crend()is valid and return type is implementation defined.
Possible implementation
template<typename R, BidirRng = remove_cvref<R>> concept BidirectionalRange = ForwardRange<BidirRng> && BidirectionalIterator<BidirRng::iterator_type> && requires(BidirRng bidirrng, const BidirRng cbidirrng) { { bidirrng.rbegin() } -> /* implementation defined */; { bidirrng.rend() } -> /* implementation defined */; { cbidirrng.crbegin() } -> /* implementation defined */; { cbidirrng.crend() } -> /* implementation defined */; };
- Refines the
RandomAccessRange¶
-
template<typename
RndAccRng>
conceptRandomAccessRange¶ - Refines the
template <typename Rng> BidirectionalRangeconcept. RndAccRng::iterator_typemodels thetemplate <typename I> RandomAccessIteratorconcept.RndAccRng::iterator_typeprovides methodsoperator+=,operator+,operator-=,operator-andoperator[].
Notation
-
using
difference_type= iterator_type::difference_type¶
-
const iterator_type
cit¶
-
const iterator_type
lhs¶
-
const iterator_type
rhs¶
Valid Expressions
lhs < rhsreturn-type modelstemplate<typename B> Boolean.lhs > rhsreturn-type modelstemplate<typename B> Boolean.lhs <= rhsreturn-type modelstemplate<typename B> Boolean.lhs >= rhsreturn-type modelstemplate<typename B> Boolean.it += nreturns an instance ofiterator_type&.cit + nreturns an instance ofiterator_type&&.n + citreturns an instance ofiterator_type&&.it -= nreturns an instance ofiterator_type&.cit - nreturns an instance ofiterator_type&&.cit[n]returns an instance ofiterator_type::reference.
Possible implementation
template<typename R, RndAccRng = remove_cvref<R>> concept RandomAccessRange = BidirectionalRange<RndAccRng> && RandomAccessIterator<RndAccRng::iterator_type>;
- Refines the