Working Draft, Standard for Programming Language C++ (N4713, 2017 year) - page 30

 

  Главная      Manuals     Working Draft, Standard for Programming Language C++ (N4713, 2017 year)

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     28      29      30      31     ..

 

 

 

Working Draft, Standard for Programming Language C++ (N4713, 2017 year) - page 30

 

 

template<class Iterator1, class Iterator2>
constexpr bool operator>(
const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
template<class Iterator1, class Iterator2>
constexpr bool operator>=(
const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
template<class Iterator1, class Iterator2>
constexpr auto operator-(
const move_iterator<Iterator1>& x,
const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base());
template<class Iterator>
constexpr move_iterator<Iterator> operator+(
typename move_iterator<Iterator>::difference_type n, const move_iterator<Iterator>&
x);
template<class Iterator>
constexpr move_iterator<Iterator> make_move_iterator(Iterator i);
// 27.6, stream iterators
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!=(const istream_iterator<T,charT,traits,Distance>& x,
const istream_iterator<T,charT,traits,Distance>& 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!=(const istreambuf_iterator<charT,traits>& a,
const istreambuf_iterator<charT,traits>& b);
template<class charT, class traits = char_traits<charT>>
class ostreambuf_iterator;
// 27.7, range access
template<class C> constexpr auto begin(C& c) -> decltype(c.begin());
template<class C> constexpr auto begin(const C& c) -> decltype(c.begin());
template<class C> constexpr auto end(C& c) -> decltype(c.end());
template<class C> constexpr auto end(const C& c) -> decltype(c.end());
template<class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept;
template<class T, size_t N> constexpr T* end(T (&array)[N]) noexcept;
template<class C> constexpr auto cbegin(const C& c) noexcept(noexcept(std::begin(c)))
-> decltype(std::begin(c));
template<class C> constexpr auto cend(const C& c) noexcept(noexcept(std::end(c)))
-> decltype(std::end(c));
template<class C> constexpr auto rbegin(C& c) -> decltype(c.rbegin());
template<class C> constexpr auto rbegin(const C& c) -> decltype(c.rbegin());
template<class C> constexpr auto rend(C& c) -> decltype(c.rend());
template<class C> constexpr auto rend(const C& c) -> decltype(c.rend());
template<class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]);
template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]);
template<class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il);
template<class E> constexpr reverse_iterator<const E*> rend(initializer_list<E> il);
template<class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c));
template<class C> constexpr auto crend(const C& c) -> decltype(std::rend(c));
§
27.3
862
// 27.8, container access
template<class C> constexpr auto size(const C& c) -> decltype(c.size());
template<class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept;
template<class C> [[nodiscard]] constexpr auto empty(const C& c) -> decltype(c.empty());
template<class T, size_t N> [[nodiscard]] constexpr bool empty(const T (&array)[N]) noexcept;
template<class E> [[nodiscard]] constexpr bool empty(initializer_list<E> il) noexcept;
template<class C> constexpr auto data(C& c) -> decltype(c.data());
template<class C> constexpr auto data(const C& c) -> decltype(c.data());
template<class T, size_t N> constexpr T* data(T (&array)[N]) noexcept;
template<class E> constexpr const E* data(initializer_list<E> il) noexcept;
}
27.4
Iterator primitives
[iterator.primitives]
1
To simplify the task of defining iterators, the library provides several classes and functions:
27.4.1
Iterator traits
[iterator.traits]
1
To implement algorithms only in terms of iterators, it is often necessary to determine the value and difference
types that correspond to a particular iterator type. Accordingly, it is required that if Iterator is the type of
an iterator, the types
iterator_traits<Iterator>::difference_type
iterator_traits<Iterator>::value_type
iterator_traits<Iterator>::iterator_category
be defined as the iterator’s difference type, value type and iterator category, respectively. In addition, the
types
iterator_traits<Iterator>::reference
iterator_traits<Iterator>::pointer
shall be defined as the iterator’s reference and pointer types, that is, for an iterator object a, the same type
as the type of *a and a->, respectively. In the case of an output iterator, the types
iterator_traits<Iterator>::difference_type
iterator_traits<Iterator>::value_type
iterator_traits<Iterator>::reference
iterator_traits<Iterator>::pointer
may be defined as void.
2
If Iterator has valid (17.9.2) member types difference_type, value_type, pointer, reference, and
iterator_category, iterator_traits<Iterator> shall have the following as publicly accessible mem-
bers:
using difference_type
= typename Iterator::difference_type;
using value_type
= typename Iterator::value_type;
using pointer
= typename Iterator::pointer;
using reference
= typename Iterator::reference;
using iterator_category = typename Iterator::iterator_category;
Otherwise, iterator_traits<Iterator> shall have no members by any of the above names.
It is specialized for pointers as
3
namespace std {
template<class T> struct iterator_traits<T*> {
using difference_type
= ptrdiff_t;
using value_type
= remove_cv_t<T>;
using pointer
= T*;
using reference
= T&;
using iterator_category = random_access_iterator_tag;
};
}
4
[ Example: To implement a generic reverse function, a C++ program can do the following:
template<class BidirectionalIterator>
void reverse(BidirectionalIterator first, BidirectionalIterator last) {
typename iterator_traits<BidirectionalIterator>::difference_type n =
distance(first, last);
§ 27.4.1
863
--n;
while(n > 0) {
typename iterator_traits<BidirectionalIterator>::value_type
tmp = *first;
*first++ = *--last;
*last = tmp;
n -= 2;
}
}
— end example ]
27.4.2
Standard iterator tags
[std.iterator.tags]
1
It is often desirable for a function template specialization to find out what is the most specific cate-
gory of its iterator argument, so that the function can select the most efficient algorithm at compile
time. To facilitate this, the library introduces category tag classes which are used as compile time tags
for algorithm selection. They are: input_iterator_tag, output_iterator_tag, forward_iterator_tag,
bidirectional_iterator_tag and random_access_iterator_tag. For every iterator of type Iterator,
iterator_traits<Iterator>::iterator_category shall be defined to be the most specific category tag
that describes the iterator’s behavior.
namespace std {
struct input_iterator_tag { };
struct output_iterator_tag { };
struct forward_iterator_tag: public input_iterator_tag { };
struct bidirectional_iterator_tag: public forward_iterator_tag { };
struct random_access_iterator_tag: public bidirectional_iterator_tag { };
}
2
[ Example: For a program-defined iterator BinaryTreeIterator, it could be included into the bidirectional
iterator category by specializing the iterator_traits template:
template<class T> struct iterator_traits<BinaryTreeIterator<T>> {
using iterator_category = bidirectional_iterator_tag;
using difference_type
= ptrdiff_t;
using value_type
= T;
using pointer
= T*;
using reference
= T&;
};
— end example ]
3
[ Example: If evolve() is well-defined for bidirectional iterators, but can be implemented more efficiently for
random access iterators, then the implementation is as follows:
template<class BidirectionalIterator>
inline void
evolve(BidirectionalIterator first, BidirectionalIterator last) {
evolve(first, last,
typename iterator_traits<BidirectionalIterator>::iterator_category());
}
template<class BidirectionalIterator>
void evolve(BidirectionalIterator first, BidirectionalIterator last,
bidirectional_iterator_tag) {
// more generic, but less efficient algorithm
}
template<class RandomAccessIterator>
void evolve(RandomAccessIterator first, RandomAccessIterator last,
random_access_iterator_tag) {
// more efficient, but less generic algorithm
}
— end example ]
§ 27.4.2
864
27.4.3
Iterator operations
[iterator.operations]
1
Since only random access iterators provide + and - operators, the library provides two function templates
advance and distance. These function templates use + and - for random access iterators (and are, therefore,
constant time for them); for input, forward and bidirectional iterators they use ++ to provide linear time
implementations.
template<class InputIterator, class Distance>
constexpr void advance(InputIterator& i, Distance n);
2
Requires: n shall be negative only for bidirectional and random access iterators.
3
Effects: Increments (or decrements for negative n) iterator reference i by n.
template<class InputIterator>
constexpr typename iterator_traits<InputIterator>::difference_type
distance(InputIterator first, InputIterator last);
4
Effects: If InputIterator meets the requirements of random access iterator, returns (last - first);
otherwise, returns the number of increments needed to get from first to last.
5
Requires: If InputIterator meets the requirements of random access iterator, last shall be reachable
from first or first shall be reachable from last; otherwise, last shall be reachable from first.
template<class InputIterator>
constexpr InputIterator next(InputIterator x,
typename iterator_traits<InputIterator>::difference_type n = 1);
6
Effects: Equivalent to: advance(x, n); return x;
template<class BidirectionalIterator>
constexpr BidirectionalIterator prev(BidirectionalIterator x,
typename iterator_traits<BidirectionalIterator>::difference_type n = 1);
7
Effects: Equivalent to: advance(x, -n); return x;
27.5
Iterator adaptors
[predef.iterators]
27.5.1
Reverse iterators
[reverse.iterators]
1
Class template reverse_iterator is an iterator adaptor that iterates from the end of the sequence defined
by its underlying iterator to the beginning of that sequence. The fundamental relation between a reverse
iterator and its corresponding iterator i is established by the identity: &*(reverse_iterator(i)) == &*(i
- 1).
27.5.1.1
Class template reverse_iterator
[reverse.iterator]
namespace std {
template<class Iterator>
class reverse_iterator {
public:
using iterator_type
= Iterator;
using iterator_category = typename iterator_traits<Iterator>::iterator_category;
using value_type
= typename iterator_traits<Iterator>::value_type;
using difference_type
= typename iterator_traits<Iterator>::difference_type;
using pointer
= typename iterator_traits<Iterator>::pointer;
using reference
= typename iterator_traits<Iterator>::reference;
constexpr reverse_iterator();
constexpr explicit reverse_iterator(Iterator x);
template<class U> constexpr reverse_iterator(const reverse_iterator<U>& u);
template<class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u);
constexpr Iterator base() const;
// explicit
constexpr reference operator*() const;
constexpr pointer operator->() const;
constexpr reverse_iterator& operator++();
constexpr reverse_iterator operator++(int);
constexpr reverse_iterator& operator--();
§ 27.5.1.1
865
constexpr reverse_iterator operator--(int);
constexpr reverse_iterator operator+ (difference_type n) const;
constexpr reverse_iterator& operator+=(difference_type n);
constexpr reverse_iterator operator- (difference_type n) const;
constexpr reverse_iterator& operator-=(difference_type n);
constexpr unspecified operator[](difference_type
n)
const;
protected:
Iterator current;
};
template<class Iterator1, class Iterator2>
constexpr bool operator==(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
template<class Iterator1, class Iterator2>
constexpr bool operator<(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
template<class Iterator1, class Iterator2>
constexpr bool operator!=(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
template<class Iterator1, class Iterator2>
constexpr bool operator>(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
template<class Iterator1, class Iterator2>
constexpr bool operator>=(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
template<class Iterator1, class Iterator2>
constexpr bool operator<=(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
template<class Iterator1, class Iterator2>
constexpr auto operator-(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y) ->
decltype(y.base()
-
x.base());
template<class Iterator>
constexpr reverse_iterator<Iterator> operator+(
typename reverse_iterator<Iterator>::difference_type n,
const reverse_iterator<Iterator>& x);
template<class Iterator>
constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i);
}
27.5.1.2
reverse_iterator requirements
[reverse.iter.requirements]
1
The template parameter Iterator shall meet all the requirements of a Bidirectional Iterator (27.2.6).
2
Additionally, Iterator shall meet the requirements of a random access iterator (27.2.7) if any of the
members operator+ (27.5.1.3.8), operator- (27.5.1.3.10), operator+= (27.5.1.3.9), operator-= (27.5.1.3.11),
operator[] (27.5.1.3.12), or the non-member operators operator< (27.5.1.3.14), operator> (27.5.1.3.16),
operator<= (27.5.1.3.18), operator>= (27.5.1.3.17), operator- (27.5.1.3.19) or operator+ (27.5.1.3.20) are
referenced in a way that requires instantiation (17.8.1).
27.5.1.3
reverse_iterator operations
[reverse.iter.ops]
27.5.1.3.1
reverse_iterator constructor
[reverse.iter.cons]
constexpr reverse_iterator();
1
Effects: Value-initializes current. Iterator operations applied to the resulting iterator have defined
§ 27.5.1.3.1
866
behavior if and only if the corresponding operations are defined on a value-initialized iterator of type
Iterator.
constexpr explicit reverse_iterator(Iterator x);
2
Effects: Initializes current with x.
template<class U> constexpr reverse_iterator(const reverse_iterator<U>&
u);
3
Effects: Initializes current with u.current.
27.5.1.3.2
reverse_iterator::operator=
[reverse.iter.op=]
template<class U>
constexpr reverse_iterator&
operator=(const reverse_iterator<U>& u);
1
Effects: Assigns u.base() to current.
2
Returns: *this.
27.5.1.3.3
Conversion
[reverse.iter.conv]
constexpr Iterator base() const;
// explicit
1
Returns: current.
27.5.1.3.4
operator*
[reverse.iter.op.star]
constexpr reference operator*() const;
1
Effects: As if by:
Iterator tmp = current;
return *--tmp;
27.5.1.3.5
operator->
[reverse.iter.opref]
constexpr pointer operator->() const;
1
Returns: addressof(operator*()).
27.5.1.3.6
operator++
[reverse.iter.op++]
constexpr reverse_iterator& operator++();
1
Effects: As if by: --current;
2
Returns: *this.
constexpr reverse_iterator operator++(int);
3
Effects: As if by:
reverse_iterator tmp = *this;
--current;
return tmp;
27.5.1.3.7
operator--
[reverse.iter.op--]
constexpr reverse_iterator& operator--();
1
Effects: As if by ++current.
2
Returns: *this.
constexpr reverse_iterator operator--(int);
3
Effects: As if by:
reverse_iterator tmp = *this;
++current;
return tmp;
§ 27.5.1.3.7
867
27.5.1.3.8
operator+
[reverse.iter.op+]
constexpr reverse_iterator operator+(difference_type n) const;
1
Returns: reverse_iterator(current-n).
27.5.1.3.9
operator+=
[reverse.iter.op+=]
constexpr reverse_iterator& operator+=(difference_type n);
1
Effects: As if by: current -= n;
2
Returns: *this.
27.5.1.3.10
operator-
[reverse.iter.op-]
constexpr reverse_iterator operator-(difference_type n) const;
1
Returns: reverse_iterator(current+n).
27.5.1.3.11
operator-=
[reverse.iter.op-=]
constexpr reverse_iterator& operator-=(difference_type n);
1
Effects: As if by: current += n;
2
Returns: *this.
27.5.1.3.12
operator[]
[reverse.iter.opindex]
constexpr unspecified operator[](difference_type
n)
const;
1
Returns: current[-n-1].
27.5.1.3.13
operator==
[reverse.iter.op==]
template<class Iterator1, class Iterator2>
constexpr bool operator==(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
1
Returns: x.current == y.current.
27.5.1.3.14
operator<
[reverse.iter.op<]
template<class Iterator1, class Iterator2>
constexpr bool operator<(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
1
Returns: x.current > y.current.
27.5.1.3.15
operator!=
[reverse.iter.op!=]
template<class Iterator1, class Iterator2>
constexpr bool operator!=(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
1
Returns: x.current != y.current.
27.5.1.3.16
operator>
[reverse.iter.op>]
template<class Iterator1, class Iterator2>
constexpr bool operator>(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
1
Returns: x.current < y.current.
§ 27.5.1.3.16
868
27.5.1.3.17
operator>=
[reverse.iter.op>=]
template<class Iterator1, class Iterator2>
constexpr bool operator>=(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
1
Returns: x.current <= y.current.
27.5.1.3.18
operator<=
[reverse.iter.op<=]
template<class Iterator1, class Iterator2>
constexpr bool operator<=(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y);
1
Returns: x.current >= y.current.
27.5.1.3.19
operator-
[reverse.iter.opdiff]
template<class Iterator1, class Iterator2>
constexpr auto operator-(
const reverse_iterator<Iterator1>& x,
const reverse_iterator<Iterator2>& y) -> decltype(y.base()
-
x.base());
1
Returns: y.current - x.current.
27.5.1.3.20
operator+
[reverse.iter.opsum]
template<class Iterator>
constexpr reverse_iterator<Iterator> operator+(
typename reverse_iterator<Iterator>::difference_type n,
const reverse_iterator<Iterator>& x);
1
Returns: reverse_iterator<Iterator> (x.current - n).
27.5.1.3.21
Non-member function make_reverse_iterator()
[reverse.iter.make]
template<class Iterator>
constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i);
1
Returns: reverse_iterator<Iterator>(i).
27.5.2
Insert iterators
[insert.iterators]
1
To make it possible to deal with insertion in the same way as writing into an array, a special kind of iterator
adaptors, called insert iterators, are provided in the library. With regular iterator classes,
while (first != last) *result++ = *first++;
causes a range [first, last) to be copied into a range starting with result. The same code with result
being an insert iterator will insert corresponding elements into the container. This device allows all of the
copying algorithms in the library to work in the insert mode instead of the regular overwrite mode.
2
An insert iterator is constructed from a container and possibly one of its iterators pointing to where
insertion takes place if it is neither at the beginning nor at the end of the container. Insert iterators
satisfy the requirements of output iterators. operator* returns the insert iterator itself. The assignment
operator=(const T& x) is defined on insert iterators to allow writing into them, it inserts x right before
where the insert iterator is pointing. In other words, an insert iterator is like a cursor pointing into the
container where the insertion takes place. back_insert_iterator inserts elements at the end of a container,
front_insert_iterator inserts elements at the beginning of a container, and insert_iterator inserts
elements where the iterator points to in a container. back_inserter, front_inserter, and inserter are
three functions making the insert iterators out of a container.
27.5.2.1
Class template back_insert_iterator
[back.insert.iterator]
namespace std {
template<class Container>
class back_insert_iterator {
protected:
Container* container;
§ 27.5.2.1
869
public:
using iterator_category = output_iterator_tag;
using value_type
= void;
using difference_type
= void;
using pointer
= void;
using reference
= void;
using container_type
= Container;
explicit back_insert_iterator(Container& x);
back_insert_iterator& operator=(const typename Container::value_type& value);
back_insert_iterator& operator=(typename Container::value_type&& value);
back_insert_iterator& operator*();
back_insert_iterator& operator++();
back_insert_iterator operator++(int);
};
template<class Container>
back_insert_iterator<Container> back_inserter(Container& x);
}
27.5.2.2
back_insert_iterator operations
[back.insert.iter.ops]
27.5.2.2.1
back_insert_iterator constructor
[back.insert.iter.cons]
explicit back_insert_iterator(Container& x);
1
Effects: Initializes container with addressof(x).
27.5.2.2.2
back_insert_iterator::operator=
[back.insert.iter.op=]
back_insert_iterator& operator=(const typename Container::value_type& value);
1
Effects: As if by: container->push_back(value);
2
Returns: *this.
back_insert_iterator& operator=(typename Container::value_type&& value);
3
Effects: As if by: container->push_back(std::move(value));
4
Returns: *this.
27.5.2.2.3
back_insert_iterator::operator*
[back.insert.iter.op*]
back_insert_iterator& operator*();
1
Returns: *this.
27.5.2.2.4
back_insert_iterator::operator++
[back.insert.iter.op++]
back_insert_iterator& operator++();
back_insert_iterator operator++(int);
1
Returns: *this.
27.5.2.2.5
back_inserter
[back.inserter]
template<class Container>
back_insert_iterator<Container> back_inserter(Container& x);
1
Returns: back_insert_iterator<Container>(x).
27.5.2.3
Class template front_insert_iterator
[front.insert.iterator]
namespace std {
template<class Container>
class front_insert_iterator {
protected:
Container* container;
§ 27.5.2.3
870
public:
using iterator_category = output_iterator_tag;
using value_type
= void;
using difference_type
= void;
using pointer
= void;
using reference
= void;
using container_type
= Container;
explicit front_insert_iterator(Container& x);
front_insert_iterator& operator=(const typename Container::value_type& value);
front_insert_iterator& operator=(typename Container::value_type&& value);
front_insert_iterator& operator*();
front_insert_iterator& operator++();
front_insert_iterator operator++(int);
};
template<class Container>
front_insert_iterator<Container> front_inserter(Container& x);
}
27.5.2.4
front_insert_iterator operations
[front.insert.iter.ops]
27.5.2.4.1
front_insert_iterator constructor
[front.insert.iter.cons]
explicit front_insert_iterator(Container& x);
1
Effects: Initializes container with addressof(x).
27.5.2.4.2
front_insert_iterator::operator=
[front.insert.iter.op=]
front_insert_iterator& operator=(const typename Container::value_type& value);
1
Effects: As if by: container->push_front(value);
2
Returns: *this.
front_insert_iterator& operator=(typename Container::value_type&& value);
3
Effects: As if by: container->push_front(std::move(value));
4
Returns: *this.
27.5.2.4.3
front_insert_iterator::operator*
[front.insert.iter.op*]
front_insert_iterator& operator*();
1
Returns: *this.
27.5.2.4.4
front_insert_iterator::operator++
[front.insert.iter.op++]
front_insert_iterator& operator++();
front_insert_iterator operator++(int);
1
Returns: *this.
27.5.2.4.5
front_inserter
[front.inserter]
template<class Container>
front_insert_iterator<Container> front_inserter(Container& x);
1
Returns: front_insert_iterator<Container>(x).
27.5.2.5
Class template insert_iterator
[insert.iterator]
namespace std {
template<class Container>
class insert_iterator {
protected:
Container* container;
typename Container::iterator iter;
§ 27.5.2.5
871
public:
using iterator_category = output_iterator_tag;
using value_type
= void;
using difference_type
= void;
using pointer
= void;
using reference
= void;
using container_type
= Container;
insert_iterator(Container& x, typename Container::iterator i);
insert_iterator& operator=(const typename Container::value_type& value);
insert_iterator& operator=(typename Container::value_type&& value);
insert_iterator& operator*();
insert_iterator& operator++();
insert_iterator& operator++(int);
};
template<class Container>
insert_iterator<Container> inserter(Container& x, typename Container::iterator i);
}
27.5.2.6
insert_iterator operations
[insert.iter.ops]
27.5.2.6.1
insert_iterator constructor
[insert.iter.cons]
insert_iterator(Container& x, typename Container::iterator i);
1
Effects: Initializes container with addressof(x) and iter with i.
27.5.2.6.2
insert_iterator::operator=
[insert.iter.op=]
insert_iterator& operator=(const typename Container::value_type& value);
1
Effects: As if by:
iter = container->insert(iter, value);
++iter;
2
Returns: *this.
insert_iterator& operator=(typename Container::value_type&& value);
3
Effects: As if by:
iter = container->insert(iter, std::move(value));
++iter;
4
Returns: *this.
27.5.2.6.3
insert_iterator::operator*
[insert.iter.op*]
insert_iterator& operator*();
1
Returns: *this.
27.5.2.6.4
insert_iterator::operator++
[insert.iter.op++]
insert_iterator& operator++();
insert_iterator& operator++(int);
1
Returns: *this.
27.5.2.6.5
inserter
[inserter]
template<class Container>
insert_iterator<Container> inserter(Container& x, typename Container::iterator i);
1
Returns: insert_iterator<Container>(x, i).
§ 27.5.2.6.5
872
27.5.3
Move iterators
[move.iterators]
1
Class template move_iterator is an iterator adaptor with the same behavior as the underlying iterator except
that its indirection operator implicitly converts the value returned by the underlying iterator’s indirection
operator to an rvalue. Some generic algorithms can be called with move iterators to replace copying with
moving.
2
[ Example:
list<string> s;
// populate the list s
vector<string> v1(s.begin(), s.end());
// copies strings into v1
vector<string> v2(make_move_iterator(s.begin()),
make_move_iterator(s.end())); // moves strings into v2
— end example ]
27.5.3.1
Class template move_iterator
[move.iterator]
namespace std {
template<class Iterator>
class move_iterator {
public:
using iterator_type
= Iterator;
using iterator_category = typename iterator_traits<Iterator>::iterator_category;
using value_type
= typename iterator_traits<Iterator>::value_type;
using difference_type
= typename iterator_traits<Iterator>::difference_type;
using pointer
= Iterator;
using reference
= see below ;
constexpr move_iterator();
constexpr explicit move_iterator(Iterator i);
template<class U> constexpr move_iterator(const move_iterator<U>& u);
template<class U> constexpr move_iterator& operator=(const move_iterator<U>&
u);
constexpr iterator_type base() const;
constexpr reference operator*() const;
constexpr pointer operator->() const;
constexpr move_iterator& operator++();
constexpr move_iterator operator++(int);
constexpr move_iterator& operator--();
constexpr move_iterator operator--(int);
constexpr move_iterator operator+(difference_type n) const;
constexpr move_iterator& operator+=(difference_type n);
constexpr move_iterator operator-(difference_type n) const;
constexpr move_iterator& operator-=(difference_type n);
constexpr unspecified operator[](difference_type n) const;
private:
Iterator current;
// exposition only
};
template<class Iterator1, class Iterator2>
constexpr bool operator==(
const move_iterator<Iterator1>& x, const move_iterator<Iterator2>&
y);
template<class Iterator1, class Iterator2>
constexpr bool operator!=(
const move_iterator<Iterator1>& x, const move_iterator<Iterator2>&
y);
template<class Iterator1, class Iterator2>
constexpr bool operator<(
const move_iterator<Iterator1>& x, const move_iterator<Iterator2>&
y);
template<class Iterator1, class Iterator2>
constexpr bool operator<=(
const move_iterator<Iterator1>& x, const move_iterator<Iterator2>&
y);
§
27.5.3.1
873
template<class Iterator1, class Iterator2>
constexpr bool operator>(
const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
template<class Iterator1, class Iterator2>
constexpr bool operator>=(
const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
template<class Iterator1, class Iterator2>
constexpr auto operator-(
const move_iterator<Iterator1>& x,
const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base());
template<class Iterator>
constexpr move_iterator<Iterator> operator+(
typename move_iterator<Iterator>::difference_type n, const move_iterator<Iterator>& x);
template<class Iterator>
constexpr move_iterator<Iterator> make_move_iterator(Iterator i);
}
1
Let R denote iterator_traits<Iterator>::reference. If is_reference_v<R > is true, the template
specialization move_iterator<Iterator> shall define the nested type named reference as a synonym for
remove_reference_t<R >&&, otherwise as a synonym for R .
27.5.3.2
move_iterator requirements
[move.iter.requirements]
1
The template parameter Iterator shall meet the requirements of an input iterator (27.2.3). Additionally, if
any of the bidirectional or random access traversal functions are instantiated, the template parameter shall
meet the requirements for a Bidirectional Iterator (27.2.6) or a Random Access Iterator (27.2.7), respectively.
27.5.3.3
move_iterator operations
[move.iter.ops]
27.5.3.3.1
move_iterator constructors
[move.iter.op.const]
constexpr move_iterator();
1
Effects: Constructs a move_iterator, value-initializing current. Iterator operations applied to the
resulting iterator have defined behavior if and only if the corresponding operations are defined on a
value-initialized iterator of type Iterator.
constexpr explicit move_iterator(Iterator i);
2
Effects: Constructs a move_iterator, initializing current with i.
template<class U> constexpr move_iterator(const move_iterator<U>& u);
3
Effects: Constructs a move_iterator, initializing current with u.base().
4
Requires: U shall be convertible to Iterator.
27.5.3.3.2
move_iterator::operator=
[move.iter.op=]
template<class U> constexpr move_iterator& operator=(const move_iterator<U>&
u);
1
Effects: Assigns u.base() to current.
2
Requires: U shall be convertible to Iterator.
27.5.3.3.3
move_iterator conversion
[move.iter.op.conv]
constexpr Iterator base() const;
1
Returns: current.
27.5.3.3.4
move_iterator::operator*
[move.iter.op.star]
constexpr reference operator*() const;
1
Returns: static_cast<reference>(*current).
27.5.3.3.5
move_iterator::operator->
[move.iter.op.ref]
constexpr pointer operator->() const;
1
Returns: current.
§ 27.5.3.3.5
874
27.5.3.3.6
move_iterator::operator++
[move.iter.op.incr]
constexpr move_iterator& operator++();
1
Effects: As if by ++current.
2
Returns: *this.
constexpr move_iterator operator++(int);
3
Effects: As if by:
move_iterator tmp = *this;
++current;
return tmp;
27.5.3.3.7
move_iterator::operator--
[move.iter.op.decr]
constexpr move_iterator& operator--();
1
Effects: As if by --current.
2
Returns: *this.
constexpr move_iterator operator--(int);
3
Effects: As if by:
move_iterator tmp = *this;
--current;
return tmp;
27.5.3.3.8
move_iterator::operator+
[move.iter.op.+]
constexpr move_iterator operator+(difference_type
n)
const;
1
Returns: move_iterator(current + n).
27.5.3.3.9
move_iterator::operator+=
[move.iter.op.+=]
constexpr move_iterator& operator+=(difference_type n);
1
Effects: As if by: current += n;
2
Returns: *this.
27.5.3.3.10
move_iterator::operator-
[move.iter.op.-]
constexpr move_iterator operator-(difference_type n) const;
1
Returns: move_iterator(current - n).
27.5.3.3.11
move_iterator::operator-=
[move.iter.op.-=]
constexpr move_iterator& operator-=(difference_type n);
1
Effects: As if by: current -= n;
2
Returns: *this.
27.5.3.3.12
move_iterator::operator[]
[move.iter.op.index]
constexpr unspecified operator[](difference_type n) const;
1
Returns: std::move(current[n]).
27.5.3.3.13
move_iterator comparisons
[move.iter.op.comp]
template<class Iterator1, class Iterator2>
constexpr bool operator==(const move_iterator<Iterator1>& x,
const
move_iterator<Iterator2>& y);
1
Returns: x.base() == y.base().
template<class Iterator1, class Iterator2>
constexpr bool operator!=(const move_iterator<Iterator1>& x,
const
move_iterator<Iterator2>& y);
2
Returns: !(x == y).
§ 27.5.3.3.13
875
template<class Iterator1, class Iterator2>
constexpr bool operator<(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
3
Returns: x.base() < y.base().
template<class Iterator1, class Iterator2>
constexpr bool operator<=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
4
Returns: !(y < x).
template<class Iterator1, class Iterator2>
constexpr bool operator>(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
5
Returns: y < x.
template<class Iterator1, class Iterator2>
constexpr bool operator>=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
6
Returns: !(x < y).
27.5.3.3.14
move_iterator non-member functions
[move.iter.nonmember]
template<class Iterator1, class Iterator2>
constexpr auto operator-(
const move_iterator<Iterator1>& x,
const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base());
1
Returns: x.base() - y.base().
template<class Iterator>
constexpr move_iterator<Iterator> operator+(
typename move_iterator<Iterator>::difference_type n, const move_iterator<Iterator>& x);
2
Returns: x + n.
template<class Iterator>
constexpr move_iterator<Iterator> make_move_iterator(Iterator i);
3
Returns: move_iterator<Iterator>(i).
27.6
Stream iterators
[stream.iterators]
1
To make it possible for algorithmic templates to work directly with input/output streams, appropriate
iterator-like class templates are provided.
[ Example:
partial_sum(istream_iterator<double, char>(cin),
istream_iterator<double, char>(),
ostream_iterator<double, char>(cout, "\n"));
reads a file containing floating-point numbers from cin, and prints the partial sums onto cout.
— end
example ]
27.6.1
Class template istream_iterator
[istream.iterator]
1
The class template istream_iterator is an input iterator (27.2.3) that reads (using operator>>) successive
elements from the input stream for which it was constructed. After it is constructed, and every time ++ is
used, the iterator reads and stores a value of T. If the iterator fails to read and store a value of T (fail() on
the stream returns true), the iterator becomes equal to the end-of-stream iterator value. The constructor
with no arguments istream_iterator() always constructs an end-of-stream input iterator object, which is
the only legitimate iterator to be used for the end condition. The result of operator* on an end-of-stream
iterator is not defined. For any other iterator value a const T& is returned. The result of operator-> on an
end-of-stream iterator is not defined. For any other iterator value a const T* is returned. The behavior of
a program that applies operator++() to an end-of-stream iterator is undefined. It is impossible to store
things into istream iterators. The type T shall meet the DefaultConstructible, CopyConstructible, and
CopyAssignable requirements.
2
Two end-of-stream iterators are always equal. An end-of-stream iterator is not equal to a non-end-of-stream
iterator. Two non-end-of-stream iterators are equal when they are constructed from the same stream.
§ 27.6.1
876
namespace std {
template<class T, class charT = char, class traits = char_traits<charT>,
class Distance = ptrdiff_t>
class istream_iterator {
public:
using iterator_category = input_iterator_tag;
using value_type
= T;
using difference_type
= Distance;
using pointer
= const T*;
using reference
= const T&;
using char_type
= charT;
using traits_type
= traits;
using istream_type
= basic_istream<charT,traits>;
constexpr istream_iterator();
istream_iterator(istream_type& s);
istream_iterator(const istream_iterator& x) = default;
~istream_iterator() = default;
const T& operator*() const;
const T* operator->() const;
istream_iterator& operator++();
istream_iterator operator++(int);
private:
basic_istream<charT,traits>* in_stream; // exposition only
T value;
// exposition only
};
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!=(const istream_iterator<T,charT,traits,Distance>&
x,
const istream_iterator<T,charT,traits,Distance>& y);
}
27.6.1.1
istream_iterator constructors and destructor
[istream.iterator.cons]
constexpr istream_iterator();
1
Effects: Constructs the end-of-stream iterator. If is_trivially_default_constructible_v<T> is
true, then this constructor is a constexpr constructor.
2
Postconditions: in_stream == 0.
istream_iterator(istream_type& s);
3
Effects: Initializes in_stream with addressof(s). value may be initialized during construction or the
first time it is referenced.
4
Postconditions: in_stream == addressof(s).
istream_iterator(const istream_iterator& x) = default;
5
Effects: Constructs a copy of x. If is_trivially_copy_constructible_v<T> is true, then this
constructor is a trivial copy constructor.
6
Postconditions: in_stream == x.in_stream.
~istream_iterator() = default;
7
Effects: The iterator is destroyed. If is_trivially_destructible_v<T> is true, then this destructor
is a trivial destructor.
§ 27.6.1.1
877
27.6.1.2
istream_iterator operations
[istream.iterator.ops]
const T& operator*() const;
1
Returns: value.
const T* operator->() const;
2
Returns: addressof(operator*()).
istream_iterator& operator++();
3
Requires: in_stream != 0.
4
Effects: As if by: *in_stream >> value;
5
Returns: *this.
istream_iterator operator++(int);
6
Requires: in_stream != 0.
7
Effects: As if by:
istream_iterator tmp = *this;
*in_stream >> value;
return (tmp);
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);
8
Returns: x.in_stream == y.in_stream.
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);
9
Returns: !(x == y)
27.6.2
Class template ostream_iterator
[ostream.iterator]
1
ostream_iterator writes (using operator<<) successive elements onto the output stream from which it was
constructed. If it was constructed with charT* as a constructor argument, this string, called a delimiter
string, is written to the stream after every T is written. It is not possible to get a value out of the output
iterator. Its only use is as an output iterator in situations like
while (first != last)
*result++ = *first++;
2
ostream_iterator is defined as:
namespace std {
template<class T, class charT = char, class traits = char_traits<charT>>
class ostream_iterator {
public:
using iterator_category = output_iterator_tag;
using value_type
= void;
using difference_type
= void;
using pointer
= void;
using reference
= void;
using char_type
= charT;
using traits_type
= traits;
using ostream_type
= basic_ostream<charT,traits>;
ostream_iterator(ostream_type& s);
ostream_iterator(ostream_type& s, const charT* delimiter);
ostream_iterator(const ostream_iterator& x);
~ostream_iterator();
ostream_iterator& operator=(const T& value);
§ 27.6.2
878
ostream_iterator& operator*();
ostream_iterator& operator++();
ostream_iterator& operator++(int);
private:
basic_ostream<charT,traits>* out_stream;
// exposition only
const charT* delim;
// exposition only
};
}
27.6.2.1
ostream_iterator constructors and destructor
[ostream.iterator.cons.des]
ostream_iterator(ostream_type& s);
1
Effects: Initializes out_stream with addressof(s) and delim with null.
ostream_iterator(ostream_type& s, const charT* delimiter);
2
Effects: Initializes out_stream with addressof(s) and delim with delimiter.
ostream_iterator(const ostream_iterator& x);
3
Effects: Constructs a copy of x.
~ostream_iterator();
4
Effects: The iterator is destroyed.
27.6.2.2
ostream_iterator operations
[ostream.iterator.ops]
ostream_iterator& operator=(const T& value);
1
Effects: As if by:
*out_stream << value;
if (delim != 0)
*out_stream << delim;
return *this;
ostream_iterator& operator*();
2
Returns: *this.
ostream_iterator& operator++();
ostream_iterator& operator++(int);
3
Returns: *this.
27.6.3
Class template istreambuf_iterator
[istreambuf.iterator]
1
The class template istreambuf_iterator defines an input iterator (27.2.3) that reads successive characters
from the streambuf for which it was constructed. operator* provides access to the current input character,
if any. Each time operator++ is evaluated, the iterator advances to the next input character. If the end
of stream is reached (streambuf_type::sgetc() returns traits::eof()), the iterator becomes equal to
the end-of-stream iterator value. The default constructor istreambuf_iterator() and the constructor
istreambuf_iterator(0) both construct an end-of-stream iterator object suitable for use as an end-of-range.
All specializations of istreambuf_iterator shall have a trivial copy constructor, a constexpr default
constructor, and a trivial destructor.
2
The result of operator*() on an end-of-stream iterator is undefined. For any other iterator value a char_type
value is returned. It is impossible to assign a character via an input iterator.
namespace std {
template<class charT, class traits = char_traits<charT>>
class istreambuf_iterator {
public:
using iterator_category = input_iterator_tag;
using value_type
= charT;
using difference_type
= typename traits::off_type;
using pointer
= unspecified ;
using reference
= charT;
§ 27.6.3
879
using char_type
= charT;
using traits_type
= traits;
using int_type
= typename traits::int_type;
using streambuf_type
= basic_streambuf<charT,traits>;
using istream_type
= basic_istream<charT,traits>;
class proxy;
// exposition only
constexpr istreambuf_iterator() noexcept;
istreambuf_iterator(const istreambuf_iterator&) noexcept
= default;
~istreambuf_iterator() = default;
istreambuf_iterator(istream_type& s) noexcept;
istreambuf_iterator(streambuf_type* s) noexcept;
istreambuf_iterator(const proxy& p) noexcept;
charT operator*() const;
istreambuf_iterator& operator++();
proxy operator++(int);
bool equal(const istreambuf_iterator& b) const;
private:
streambuf_type* sbuf_;
// exposition only
};
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!=(const istreambuf_iterator<charT,traits>&
a,
const istreambuf_iterator<charT,traits>& b);
}
27.6.3.1
Class template istreambuf_iterator::proxy
[istreambuf.iterator.proxy]
namespace std {
template<class charT, class traits = char_traits<charT>>
class istreambuf_iterator<charT, traits>::proxy { // exposition only
charT keep_;
basic_streambuf<charT,traits>* sbuf_;
proxy(charT c, basic_streambuf<charT,traits>* sbuf)
: keep_(c), sbuf_(sbuf) { }
public:
charT operator*() { return keep_; }
};
}
1
Class istreambuf_iterator<charT,traits>::proxy is for exposition only. An implementation is permit-
ted to provide equivalent functionality without providing a class with this name. Class istreambuf_-
iterator<charT, traits>::proxy provides a temporary placeholder as the return value of the post-
increment operator (operator++). It keeps the character pointed to by the previous value of the iterator for
some possible future access to get the character.
27.6.3.2
istreambuf_iterator constructors
[istreambuf.iterator.cons]
1
For each istreambuf_iterator constructor in this subclause, an end-of-stream iterator is constructed if and
only if the exposition-only member sbuf_ is initialized with a null pointer value.
constexpr istreambuf_iterator() noexcept;
2
Effects: Initializes sbuf_ with nullptr.
istreambuf_iterator(istream_type& s) noexcept;
3
Effects: Initializes sbuf_ with s.rdbuf().
istreambuf_iterator(streambuf_type* s) noexcept;
4
Effects: Initializes sbuf_ with s.
§ 27.6.3.2
880
istreambuf_iterator(const proxy& p) noexcept;
5
Effects: Initializes sbuf_ with p.sbuf_.
27.6.3.3
istreambuf_iterator operations
[istreambuf.iterator.ops]
charT operator*() const
1
Returns: The character obtained via the streambuf member sbuf_->sgetc().
istreambuf_iterator& operator++();
2
Effects: As if by sbuf_->sbumpc().
3
Returns: *this.
proxy operator++(int);
4
Returns: proxy(sbuf_->sbumpc(), sbuf_).
bool equal(const istreambuf_iterator& b) const;
5
Returns: true if and only if both iterators are at end-of-stream, or neither is at end-of-stream, regardless
of what streambuf object they use.
template<class charT, class traits>
bool operator==(const istreambuf_iterator<charT,traits>& a,
const istreambuf_iterator<charT,traits>& b);
6
Returns: a.equal(b).
template<class charT, class traits>
bool operator!=(const istreambuf_iterator<charT,traits>& a,
const istreambuf_iterator<charT,traits>& b);
7
Returns: !a.equal(b).
27.6.4
Class template ostreambuf_iterator
[ostreambuf.iterator]
namespace std {
template<class charT, class traits = char_traits<charT>>
class ostreambuf_iterator {
public:
using iterator_category = output_iterator_tag;
using value_type
= void;
using difference_type
= void;
using pointer
= void;
using reference
= void;
using char_type
= charT;
using traits_type
= traits;
using streambuf_type
= basic_streambuf<charT,traits>;
using ostream_type
= basic_ostream<charT,traits>;
ostreambuf_iterator(ostream_type& s) noexcept;
ostreambuf_iterator(streambuf_type* s) noexcept;
ostreambuf_iterator& operator=(charT c);
ostreambuf_iterator& operator*();
ostreambuf_iterator& operator++();
ostreambuf_iterator& operator++(int);
bool failed() const noexcept;
private:
streambuf_type* sbuf_;
// exposition only
};
}
1
The class template ostreambuf_iterator writes successive characters onto the output stream from which it
was constructed. It is not possible to get a character value out of the output iterator.
§ 27.6.4
881
27.6.4.1
ostreambuf_iterator constructors
[ostreambuf.iter.cons]
ostreambuf_iterator(ostream_type& s) noexcept;
1
Requires: s.rdbuf() shall not be a null pointer.
2
Effects: Initializes sbuf_ with s.rdbuf().
ostreambuf_iterator(streambuf_type* s) noexcept;
3
Requires: s shall not be a null pointer.
4
Effects: Initializes sbuf_ with s.
27.6.4.2
ostreambuf_iterator operations
[ostreambuf.iter.ops]
ostreambuf_iterator& operator=(charT c);
1
Effects: If failed() yields false, calls sbuf_->sputc(c); otherwise has no effect.
2
Returns: *this.
ostreambuf_iterator& operator*();
3
Returns: *this.
ostreambuf_iterator& operator++();
ostreambuf_iterator& operator++(int);
4
Returns: *this.
bool failed() const noexcept;
5
Returns: true if in any prior use of member operator=, the call to sbuf_->sputc() returned
traits::eof(); or false otherwise.
27.7
Range access
[iterator.range]
1
In addition to being available via inclusion of the <iterator> header, the function templates in 27.7 are
available when any of the following headers are included:
<array>, <deque>, <forward_list>, <list>,
<map>, <regex>, <set>, <string>, <string_view>, <unordered_map>, <unordered_set>, and <vector>.
template<class C> constexpr auto begin(C& c) -> decltype(c.begin());
template<class C> constexpr auto begin(const C& c) -> decltype(c.begin());
2
Returns: c.begin().
template<class C> constexpr auto end(C& c) -> decltype(c.end());
template<class C> constexpr auto end(const C& c) -> decltype(c.end());
3
Returns: c.end().
template<class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept;
4
Returns: array.
template<class T, size_t N> constexpr T* end(T (&array)[N]) noexcept;
5
Returns: array + N.
template<class C> constexpr auto cbegin(const C& c) noexcept(noexcept(std::begin(c)))
-> decltype(std::begin(c));
6
Returns: std::begin(c).
template<class C> constexpr auto cend(const C& c) noexcept(noexcept(std::end(c)))
-> decltype(std::end(c));
7
Returns: std::end(c).
template<class C> constexpr auto rbegin(C& c) -> decltype(c.rbegin());
template<class C> constexpr auto rbegin(const C& c) -> decltype(c.rbegin());
8
Returns: c.rbegin().
§ 27.7
882
template<class C> constexpr auto rend(C& c) -> decltype(c.rend());
template<class C> constexpr auto rend(const C& c) -> decltype(c.rend());
9
Returns: c.rend().
template<class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]);
10
Returns: reverse_iterator<T*>(array + N).
template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]);
11
Returns: reverse_iterator<T*>(array).
template<class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il);
12
Returns: reverse_iterator<const E*>(il.end()).
template<class E> constexpr reverse_iterator<const E*> rend(initializer_list<E> il);
13
Returns: reverse_iterator<const E*>(il.begin()).
template<class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c));
14
Returns: std::rbegin(c).
template<class C> constexpr auto crend(const C& c) -> decltype(std::rend(c));
15
Returns: std::rend(c).
27.8
Container access
[iterator.container]
1
In addition to being available via inclusion of the <iterator> header, the function templates in 27.8 are
available when any of the following headers are included:
<array>, <deque>, <forward_list>, <list>,
<map>, <regex>, <set>, <string>, <unordered_map>, <unordered_set>, and <vector>.
template<class C> constexpr auto size(const C& c) -> decltype(c.size());
2
Returns: c.size().
template<class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept;
3
Returns: N.
template<class C> [[nodiscard]] constexpr auto empty(const C& c) -> decltype(c.empty());
4
Returns: c.empty().
template<class T, size_t N> [[nodiscard]] constexpr bool empty(const T (&array)[N]) noexcept;
5
Returns: false.
template<class E> [[nodiscard]] constexpr bool empty(initializer_list<E> il) noexcept;
6
Returns: il.size() == 0.
template<class C> constexpr auto data(C& c) -> decltype(c.data());
template<class C> constexpr auto data(const C& c) -> decltype(c.data());
7
Returns: c.data().
template<class T, size_t N> constexpr T* data(T (&array)[N]) noexcept;
8
Returns: array.
template<class E> constexpr const E* data(initializer_list<E> il) noexcept;
9
Returns: il.begin().
§ 27.8
883
28
Algorithms library
[algorithms]
28.1
General
[algorithms.general]
1
This Clause describes components that C++ programs may use to perform algorithmic operations on
containers (Clause 26) and other sequences.
2
The following subclauses describe components for non-modifying sequence operations, mutating sequence
operations, sorting and related operations, and algorithms from the ISO C library, as summarized in Table 100.
Table 100 — Algorithms library summary
Subclause
Header(s)
28.5
Non-modifying sequence operations
28.6
Mutating sequence operations
<algorithm>
28.7
Sorting and related operations
28.8
C library algorithms
<cstdlib>
28.2
Header <algorithm> synopsis
[algorithm.syn]
#include <initializer_list>
namespace std {
// 28.5, non-modifying sequence operations
// 28.5.1, all of
template<class InputIterator, class Predicate>
constexpr bool all_of(InputIterator first, InputIterator last, Predicate pred);
template<class ExecutionPolicy, class ForwardIterator, class Predicate>
bool all_of(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last, Predicate pred);
// 28.5.2, any of
template<class InputIterator, class Predicate>
constexpr bool any_of(InputIterator first, InputIterator last, Predicate pred);
template<class ExecutionPolicy, class ForwardIterator, class Predicate>
bool any_of(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last, Predicate pred);
// 28.5.3, none of
template<class InputIterator, class Predicate>
constexpr bool none_of(InputIterator first, InputIterator last, Predicate pred);
template<class ExecutionPolicy, class ForwardIterator, class Predicate>
bool none_of(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last, Predicate pred);
// 28.5.4, for each
template<class InputIterator, class Function>
constexpr Function for_each(InputIterator first, InputIterator last, Function f);
template<class ExecutionPolicy, class ForwardIterator, class Function>
void for_each(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last, Function f);
template<class InputIterator, class Size, class Function>
constexpr InputIterator for_each_n(InputIterator first, Size n, Function f);
template<class ExecutionPolicy, class ForwardIterator, class Size, class Function>
ForwardIterator for_each_n(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, Size n, Function f);
§ 28.2
884
// 28.5.5, find
template<class InputIterator, class T>
constexpr InputIterator find(InputIterator first, InputIterator last,
const T& value);
template<class ExecutionPolicy, class ForwardIterator, class T>
ForwardIterator find(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
const T& value);
template<class InputIterator, class Predicate>
constexpr InputIterator find_if(InputIterator first, InputIterator last,
Predicate pred);
template<class ExecutionPolicy, class ForwardIterator, class Predicate>
ForwardIterator find_if(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
Predicate pred);
template<class InputIterator, class Predicate>
constexpr InputIterator find_if_not(InputIterator first, InputIterator last,
Predicate pred);
template<class ExecutionPolicy, class ForwardIterator, class Predicate>
ForwardIterator find_if_not(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
Predicate pred);
// 28.5.6, find end
template<class ForwardIterator1, class ForwardIterator2>
constexpr ForwardIterator1
find_end(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
constexpr ForwardIterator1
find_end(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
ForwardIterator1
find_end(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template<class ExecutionPolicy, class ForwardIterator1,
class ForwardIterator2, class BinaryPredicate>
ForwardIterator1
find_end(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred);
// 28.5.7, find first
template<class InputIterator, class ForwardIterator>
constexpr InputIterator
find_first_of(InputIterator first1, InputIterator last1,
ForwardIterator first2, ForwardIterator last2);
template<class InputIterator, class ForwardIterator, class BinaryPredicate>
constexpr InputIterator
find_first_of(InputIterator first1, InputIterator last1,
ForwardIterator first2, ForwardIterator last2,
BinaryPredicate pred);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
ForwardIterator1
find_first_of(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template<class ExecutionPolicy, class ForwardIterator1,
class ForwardIterator2, class BinaryPredicate>
ForwardIterator1
§
28.2
885
find_first_of(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred);
// 28.5.8, adjacent find
template<class ForwardIterator>
constexpr ForwardIterator
adjacent_find(ForwardIterator first, ForwardIterator last);
template<class ForwardIterator, class BinaryPredicate>
constexpr ForwardIterator
adjacent_find(ForwardIterator first, ForwardIterator last,
BinaryPredicate pred);
template<class ExecutionPolicy, class ForwardIterator>
ForwardIterator
adjacent_find(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last);
template<class ExecutionPolicy, class ForwardIterator, class BinaryPredicate>
ForwardIterator
adjacent_find(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
BinaryPredicate pred);
// 28.5.9, count
template<class InputIterator, class T>
constexpr typename iterator_traits<InputIterator>::difference_type
count(InputIterator first, InputIterator last, const T& value);
template<class ExecutionPolicy, class ForwardIterator, class T>
typename iterator_traits<ForwardIterator>::difference_type
count(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last, const T& value);
template<class InputIterator, class Predicate>
constexpr typename iterator_traits<InputIterator>::difference_type
count_if(InputIterator first, InputIterator last, Predicate pred);
template<class ExecutionPolicy, class ForwardIterator, class Predicate>
typename iterator_traits<ForwardIterator>::difference_type
count_if(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last, Predicate pred);
// 28.5.10, mismatch
template<class InputIterator1, class InputIterator2>
constexpr pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2);
template<class InputIterator1, class InputIterator2, class BinaryPredicate>
constexpr pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, BinaryPredicate pred);
template<class InputIterator1, class InputIterator2>
constexpr pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2);
template<class InputIterator1, class InputIterator2, class BinaryPredicate>
constexpr pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
BinaryPredicate pred);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
pair<ForwardIterator1, ForwardIterator2>
mismatch(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2);
§ 28.2
886
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class BinaryPredicate>
pair<ForwardIterator1, ForwardIterator2>
mismatch(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, BinaryPredicate pred);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
pair<ForwardIterator1, ForwardIterator2>
mismatch(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class BinaryPredicate>
pair<ForwardIterator1, ForwardIterator2>
mismatch(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred);
// 28.5.11, equal
template<class InputIterator1, class InputIterator2>
constexpr bool equal(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2);
template<class InputIterator1, class InputIterator2, class BinaryPredicate>
constexpr bool equal(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, BinaryPredicate pred);
template<class InputIterator1, class InputIterator2>
constexpr bool equal(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2);
template<class InputIterator1, class InputIterator2, class BinaryPredicate>
constexpr bool equal(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
BinaryPredicate pred);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
bool equal(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class BinaryPredicate>
bool equal(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, BinaryPredicate pred);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
bool equal(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class BinaryPredicate>
bool equal(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred);
// 28.5.12, is permutation
template<class ForwardIterator1, class ForwardIterator2>
constexpr bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2);
template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
constexpr bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, BinaryPredicate pred);
template<class ForwardIterator1, class ForwardIterator2>
constexpr bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
§
28.2
887
template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
constexpr bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred);
// 28.5.13, search
template<class ForwardIterator1, class ForwardIterator2>
constexpr ForwardIterator1
search(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
constexpr ForwardIterator1
search(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
ForwardIterator1
search(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class BinaryPredicate>
ForwardIterator1
search(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred);
template<class ForwardIterator, class Size, class T>
constexpr ForwardIterator
search_n(ForwardIterator first, ForwardIterator last,
Size count, const T& value);
template<class ForwardIterator, class Size, class T, class BinaryPredicate>
constexpr ForwardIterator
search_n(ForwardIterator first, ForwardIterator last,
Size count, const T& value,
BinaryPredicate pred);
template<class ExecutionPolicy, class ForwardIterator, class Size, class T>
ForwardIterator
search_n(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
Size count, const T& value);
template<class ExecutionPolicy, class ForwardIterator, class Size, class T,
class BinaryPredicate>
ForwardIterator
search_n(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
Size count, const T& value,
BinaryPredicate pred);
template<class ForwardIterator, class Searcher>
constexpr ForwardIterator
search(ForwardIterator first, ForwardIterator last, const Searcher& searcher);
// 28.6, mutating sequence operations
// 28.6.1, copy
template<class InputIterator, class OutputIterator>
constexpr OutputIterator copy(InputIterator first, InputIterator last,
OutputIterator result);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
ForwardIterator2 copy(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first, ForwardIterator1 last,
ForwardIterator2 result);
§ 28.2
888
template<class InputIterator, class Size, class OutputIterator>
constexpr OutputIterator copy_n(InputIterator first, Size n,
OutputIterator result);
template<class ExecutionPolicy, class ForwardIterator1, class Size,
class ForwardIterator2>
ForwardIterator2 copy_n(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first, Size n,
ForwardIterator2 result);
template<class InputIterator, class OutputIterator, class Predicate>
constexpr OutputIterator copy_if(InputIterator first, InputIterator last,
OutputIterator result, Predicate pred);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class Predicate>
ForwardIterator2 copy_if(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first, ForwardIterator1 last,
ForwardIterator2 result, Predicate pred);
template<class BidirectionalIterator1, class BidirectionalIterator2>
constexpr BidirectionalIterator2
copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
BidirectionalIterator2 result);
// 28.6.2, move
template<class InputIterator, class OutputIterator>
constexpr OutputIterator move(InputIterator first, InputIterator last,
OutputIterator result);
template<class ExecutionPolicy, class ForwardIterator1,
class ForwardIterator2>
ForwardIterator2 move(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first, ForwardIterator1 last,
ForwardIterator2 result);
template<class BidirectionalIterator1, class BidirectionalIterator2>
constexpr BidirectionalIterator2
move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
BidirectionalIterator2 result);
// 28.6.3, swap
template<class ForwardIterator1, class ForwardIterator2>
ForwardIterator2 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
ForwardIterator2 swap_ranges(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2);
template<class ForwardIterator1, class ForwardIterator2>
void iter_swap(ForwardIterator1 a, ForwardIterator2 b);
// 28.6.4, transform
template<class InputIterator, class OutputIterator, class UnaryOperation>
constexpr OutputIterator
transform(InputIterator first, InputIterator last,
OutputIterator result, UnaryOperation op);
template<class InputIterator1, class InputIterator2, class OutputIterator,
class BinaryOperation>
constexpr OutputIterator
transform(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, OutputIterator result,
BinaryOperation binary_op);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class UnaryOperation>
ForwardIterator2
transform(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first, ForwardIterator1 last,
ForwardIterator2 result, UnaryOperation op);
§
28.2
889
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class ForwardIterator, class BinaryOperation>
ForwardIterator
transform(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator result,
BinaryOperation binary_op);
// 28.6.5, replace
template<class ForwardIterator, class T>
constexpr void replace(ForwardIterator first, ForwardIterator last,
const T& old_value, const T& new_value);
template<class ExecutionPolicy, class ForwardIterator, class T>
void replace(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
const T& old_value, const T& new_value);
template<class ForwardIterator, class Predicate, class T>
constexpr void replace_if(ForwardIterator first, ForwardIterator last,
Predicate pred, const T& new_value);
template<class ExecutionPolicy, class ForwardIterator, class Predicate, class T>
void replace_if(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
Predicate pred, const T& new_value);
template<class InputIterator, class OutputIterator, class T>
constexpr OutputIterator replace_copy(InputIterator first, InputIterator last,
OutputIterator result,
const T& old_value, const T& new_value);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class
T>
ForwardIterator2 replace_copy(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first, ForwardIterator1 last,
ForwardIterator2 result,
const T& old_value, const T& new_value);
template<class InputIterator, class OutputIterator, class Predicate, class T>
constexpr OutputIterator replace_copy_if(InputIterator first, InputIterator last,
OutputIterator result,
Predicate pred, const T& new_value);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class Predicate, class T>
ForwardIterator2 replace_copy_if(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first, ForwardIterator1 last,
ForwardIterator2 result,
Predicate pred, const T& new_value);
// 28.6.6, fill
template<class ForwardIterator, class T>
constexpr void fill(ForwardIterator first, ForwardIterator last, const T& value);
template<class ExecutionPolicy, class ForwardIterator, class T>
void fill(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last, const T& value);
template<class OutputIterator, class Size, class T>
constexpr OutputIterator fill_n(OutputIterator first, Size n, const T& value);
template<class ExecutionPolicy, class ForwardIterator,
class Size, class T>
ForwardIterator fill_n(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, Size n, const T& value);
// 28.6.7, generate
template<class ForwardIterator, class Generator>
constexpr void generate(ForwardIterator first, ForwardIterator last,
Generator gen);
template<class ExecutionPolicy, class ForwardIterator, class Generator>
void generate(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
Generator gen);
§
28.2
890
template<class OutputIterator, class Size, class Generator>
constexpr OutputIterator generate_n(OutputIterator first, Size n, Generator gen);
template<class ExecutionPolicy, class ForwardIterator, class Size, class Generator>
ForwardIterator generate_n(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, Size n, Generator gen);
// 28.6.8, remove
template<class ForwardIterator, class T>
constexpr ForwardIterator remove(ForwardIterator first, ForwardIterator last,
const T& value);
template<class ExecutionPolicy, class ForwardIterator, class T>
ForwardIterator remove(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
const T& value);
template<class ForwardIterator, class Predicate>
constexpr ForwardIterator remove_if(ForwardIterator first, ForwardIterator last,
Predicate pred);
template<class ExecutionPolicy, class ForwardIterator, class Predicate>
ForwardIterator remove_if(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
Predicate pred);
template<class InputIterator, class OutputIterator, class T>
constexpr OutputIterator
remove_copy(InputIterator first, InputIterator last,
OutputIterator result, const T& value);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class T>
ForwardIterator2
remove_copy(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first, ForwardIterator1 last,
ForwardIterator2 result, const T& value);
template<class InputIterator, class OutputIterator, class Predicate>
constexpr OutputIterator
remove_copy_if(InputIterator first, InputIterator last,
OutputIterator result, Predicate pred);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class Predicate>
ForwardIterator2
remove_copy_if(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator1 first, ForwardIterator1 last,
ForwardIterator2 result, Predicate pred);
// 28.6.9, unique
template<class ForwardIterator>
constexpr ForwardIterator unique(ForwardIterator first, ForwardIterator last);
template<class ForwardIterator, class BinaryPredicate>
constexpr ForwardIterator unique(ForwardIterator first, ForwardIterator last,
BinaryPredicate pred);
template<class ExecutionPolicy, class ForwardIterator>
ForwardIterator unique(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last);
template<class ExecutionPolicy, class ForwardIterator, class BinaryPredicate>
ForwardIterator unique(ExecutionPolicy&& exec, // see 28.4.5
ForwardIterator first, ForwardIterator last,
BinaryPredicate pred);
template<class InputIterator, class OutputIterator>
constexpr OutputIterator
unique_copy(InputIterator first, InputIterator last,
OutputIterator result);
template<class InputIterator, class OutputIterator, class BinaryPredicate>
constexpr OutputIterator
unique_copy(InputIterator first, InputIterator last,
OutputIterator result, BinaryPredicate pred);
§
28.2
891

 

 

 

 

 

 

 

Content      ..     28      29      30      31     ..