标准库头文件 <iterator>

来自cppreference.com
< cpp‎ | header
 
 
 

此头文件是迭代器库的一部分。

概念

迭代器概念
指定类型通过应用运算符 * 可读
(概念)
指定可向迭代器所引用的对象写入值
(概念)
指定 semiregular 类型能以前后自增运算符自增
(概念)
指定 weakly_incrementable 类型上的自增操作保持相等性,而且该类型为 equality_comparable
(概念)
指定该类型对象可以自增且可以解引用
(概念)
指定类型为某个 input_or_output_iterator 类型的哨位类型
(概念)
指定可对一个迭代器和一个哨位应用 - 运算符,以在常数时间计算其距离
(概念)
指定类型为输入迭代器,即可读取其所引用的值,且可前/后自增
(概念)
指定类型为给定的值类型的输出迭代器,即可向其写入该类型的值,且可前/后自增
(概念)
指定 input_iterator 为向前迭代器,支持相等比较与多趟操作
(概念)
指定 forward_iterator 为双向迭代器,支持向后移动
(概念)
指定 bidirectional_iterator 为随机访问迭代器,支持常数时间内的前进和下标访问
(概念)
指定 random_access_iterator 为连续迭代器,指代内存中连续相接的元素
(概念)
间接可调用概念
指定可调用类型能以解引用某个 readable 类型的结果进行调用
(概念)
指定可调用类型,在以解引用一个 readable 类型的结果进行调用时,满足 predicate
(概念)
指定可调用类型,在以解引用两个 readable 类型的结果进行调用时,满足 predicate
(概念)
指定可调用类型,在以解引用两个 readable 类型的结果进行调用时,满足 strict_weak_order
(概念)
常用算法要求
指定可从 readable 类型移动值给 writable 类型
(概念)
指定可从 readable 类型移动值给 writable 类型,且该移动可以通过中间对象进行
(概念)
指定可从 readable 类型复制值给 writable 类型
(概念)
指定可从 readable 类型复制值给 writable 类型,且该复制可以通过中间对象进行
(概念)
指定能交换两个 readable 类型所引用的值
(概念)
指定能比较两个 readable 类型所引用的值
(概念)
指定在原位重排元素的算法的共用要求
(概念)
指定通过复制元素将已排序序列归并到输出序列中的算法的要求
(概念)
指定重排序列为有序序列的算法的共用要求
(概念)

算法工具
计算在解引用某组 readable 类型的结果上调用可调用对象的结果
(别名模板)
用于对接受投影的算法指定制约的辅助模板
(类模板)
关联类型
计算 weakly_incrementable 类型的差类型
(类模板)
计算 readable 类型的值类型
(类模板)
计算迭代器的关联类型
(别名模板)
原语
为迭代器各项性质提供统一接口
(类模板)
用于指示迭代器类别的空类类型
(类)
(C++17 中弃用)
用于简化简单的迭代器的必要类型定义的基类
(类模板)
适配器
逆序遍历的迭代器适配器
(类模板)
解引用结果为右值引用的迭代器适配器
(类模板)
用于 std::move_iterator 的哨位适配器
(类模板)
适配一个迭代器类型及其哨位为一个公共迭代器类型
(类模板)
用于知晓其边界的迭代器的默认哨位
(类)
对到范围结尾距离进行跟踪的迭代器适配器
(类模板)
始终与任何 weakly_incrementable 类型比较都不相等的哨位
(类)
用于在容器尾部插入的迭代器适配器
(类模板)
用于在容器头部插入的迭代器适配器
(类模板)
用于插入容器的迭代器适配器
(类模板)
流迭代器
std::basic_istream 读取的输入迭代器
(类模板)
写入 std::basic_ostream 的输出迭代器
(类模板)
std::basic_streambuf 读取的输入迭代器
(类模板)
写入 std::basic_streambuf 的输出迭代器
(类模板)

定制点对象

定义于命名空间 std::ranges
将解引用迭代器的结果转型为其关联的右值引用类型
(定制点对象)
交换两个可解引用对象所引用的值
(定制点对象)

函数

适配器
创建拥有从实参推出的类型的 std::reverse_iterator
(函数模板)
创建拥有从实参推出的类型的 std::move_iterator
(函数模板)
创建拥有从实参推出的类型的 std::front_insert_iterator
(函数模板)
创建拥有从实参推出的类型的 std::back_insert_iterator
(函数模板)
创建拥有从实参推出的类型的 std::insert_iterator
(函数模板)
非成员函数
比较底层迭代器
(函数模板)
令迭代器前进
(函数模板)
计算两个迭代器适配器间的距离
(函数模板)
比较底层迭代器
(函数模板)
令迭代器前进
(函数模板)
计算两个迭代器适配器间的距离
(函数模板)
比较两个 istream_iterator
(函数模板)
比较两个 istreambuf_iterator
(函数模板)
操作
令迭代器前进给定的距离
(函数模板)
返回两个迭代器间的距离
(函数模板)
(C++11)
令迭代器自增
(函数模板)
(C++11)
令迭代器自减
(函数模板)
令迭代器前进给定的距离或到给定的边界
(niebloid)
返回迭代器与哨位间的距离,或范围起始与结尾间的距离
(niebloid)
自增迭代器给定的距离或到边界
(niebloid)
自减迭代器给定的距离或到边界
(niebloid)
范围访问
(C++11)(C++14)
返回指向容器或数组起始的迭代器
(函数模板)
(C++11)(C++14)
返回指向容器或数组结尾的迭代器
(函数模板)
返回指向一个容器或数组的逆向迭代器
(函数模板)
(C++14)
返回容器或数组的逆向尾迭代器
(函数模板)
(C++17)(C++20)
返回容器或数组的大小
(函数模板)
(C++17)
检查容器是否为空
(函数模板)
(C++17)
获得指向底层数组的指针
(函数模板)

概要

#include <concepts>
 
namespace std {
  template<class T> using __with_reference = T&;  // 仅用于阐释
  template<class T> concept __Referenceable       // 仅用于阐释
    = requires { typename __with_reference<T>; };
  template<class T> concept __Dereferenceable     // 仅用于阐释
    = requires(T& t) {
      { *t } -> __Referenceable;  // 不要求保持相等性
    };
 
  // 关联类型
  // 可自增特征
  template<class> struct incrementable_traits;
  template<class T>
    using iter_difference_t = /* 见描述 */;
 
  // 可读特征
  template<class> struct readable_traits;
  template<class T>
    using iter_value_t = /* 见描述 */;
 
  // 迭代器特征
  template<class I> struct iterator_traits;
  template<class T> requires is_object_v<T> struct iterator_traits<T*>;
 
  template<__Dereferenceable T>
    using iter_reference_t = decltype(*declval<T&>());
 
  namespace ranges {
    // 定制点
    inline namespace /* 未指明 */ {
      // ranges​::​iter_move
      inline constexpr /* 未指明 */ iter_move = /* 未指明 */;
 
      // ranges​::​iter_swap
      inline constexpr /* 未指明 */ iter_swap = /* 未指明 */;
    }
  }
 
  template<__Dereferenceable T>
    requires requires(T& t) {
      { ranges::iter_move(t) } -> __Referenceable;
    }
  using iter_rvalue_reference_t
    = decltype(ranges::iter_move(declval<T&>()));
 
  // 迭代器概念
  // 概念 readable
  template<class In>
    concept readable = /* 见描述 */;
 
  template<readable T>
    using iter_common_reference_t =
      common_reference_t<iter_reference_t<T>, iter_value_t<T>&>;
 
  // 概念 writable
  template<class Out, class T>
    concept writable = /* 见描述 */;
 
  // 概念 weakly_incrementable
  template<class I>
    concept weakly_incrementable = /* 见描述 */;
 
  // 概念 incrementable
  template<class I>
    concept incrementable = /* 见描述 */;
 
  // 概念 input_or_output_iterator
  template<class I>
    concept input_or_output_iterator = /* 见描述 */;
 
  // 概念 sentinel_for
  template<class S, class I>
    concept sentinel_for = /* 见描述 */;
 
  // 概念 sized_sentinel_for
  template<class S, class I>
    inline constexpr bool disable_sized_sentinel = false;
 
  template<class S, class I>
    concept sized_sentinel_for = /* 见描述 */;
 
  // 概念 input_iterator
  template<class I>
    concept input_iterator = /* 见描述 */;
 
  // 概念 output_iterator
  template<class I, class T>
    concept output_iterator = /* 见描述 */;
 
  // 概念 forward_iterator
  template<class I>
    concept forward_iterator = /* 见描述 */;
 
  // 概念 bidirectional_iterator
  template<class I>
    concept bidirectional_iterator = /* 见描述 */;
 
  // 概念 random_access_iterator
  template<class I>
    concept random_access_iterator = /* 见描述 */;
 
  // 概念 contiguous_iterator
  template<class I>
    concept contiguous_iterator = /* 见描述 */;
 
  // 间接可调用要求
  // 间接可调用
  template<class F, class I>
    concept indirectly_unary_invocable = /* 见描述 */;
 
  template<class F, class I>
    concept indirectly_regular_unary_invocable = /* 见描述 */;
 
  template<class F, class I>
    concept indirect_unary_predicate = /* 见描述 */;
 
  template<class F, class I1, class I2 = I1>
    concept indirect_relation = /* 见描述 */;
 
  template<class F, class I1, class I2 = I1>
    concept indirect_strict_weak_order = /* 见描述 */;
 
  template<class F, class... Is>
    requires (readable<Is> && ...) && invocable<F, iter_reference_t<Is>...>
      using indirect_result_t = invoke_result_t<F, iter_reference_t<Is>...>;
 
  // projected
  template<readable I, indirectly_regular_unary_invocable<I> Proj>
    struct projected;
 
  template<weakly_incrementable I, class Proj>
    struct incrementable_traits<projected<I, Proj>>;
 
  // 常用算法要求
  // 概念 indirectly_movable
  template<class In, class Out>
    concept indirectly_movable = /* 见描述 */;
 
  template<class In, class Out>
    concept indirectly_movable_storable = /* 见描述 */;
 
  // 概念 indirectly_copyable
  template<class In, class Out>
    concept indirectly_copyable = /* 见描述 */;
 
  template<class In, class Out>
    concept indirectly_copyable_storable = /* 见描述 */;
 
  // 概念 indirectly_swappable
  template<class I1, class I2 = I1>
    concept indirectly_swappable = /* 见描述 */;
 
  // 概念 indirectly_comparable
  template<class I1, class I2, class R, class P1 = identity, class P2 = identity>
    concept indirectly_comparable = /* 见描述 */;
 
  // 概念 permutable
  template<class I>
    concept permutable = /* 见描述 */;
 
  // 概念 mergeable
  template<class I1, class I2, class Out,
      class R = ranges::less, class P1 = identity, class P2 = identity>
    concept mergeable = /* 见描述 */;
 
  // 概念 sortable
  template<class I, class R = ranges::less, class P = identity>
    concept sortable = /* 见描述 */;
 
  // 原语
  // 迭代器标签
  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 { };
  struct contiguous_iterator_tag: public random_access_iterator_tag { };
 
  // 迭代器操作
  template<class InputIter, class Distance>
    constexpr void
      advance(InputIter& i, Distance n);
  template<class InputIter>
    constexpr typename iterator_traits<InputIter>::difference_type
      distance(InputIter first, InputIter last);
  template<class InputIter>
    constexpr InputIter
      next(InputIter x, typename iterator_traits<InputIter>::difference_type n = 1);
  template<class BidirectionalIter>
    constexpr BidirectionalIter
      prev(BidirectionalIter x,
           typename iterator_traits<BidirectionalIter>::difference_type n = 1);
 
  // 范围迭代器操作
  namespace ranges {
    // ranges​::​advance
    template<input_or_output_iterator I>
      constexpr void advance(I& i, iter_difference_t<I> n);
    template<input_or_output_iterator I, sentinel_for<I> S>
      constexpr void advance(I& i, S bound);
    template<input_or_output_iterator I, sentinel_for<I> S>
      constexpr iter_difference_t<I> advance(I& i, iter_difference_t<I> n, S bound);
 
    // ranges​::​distance
    template<input_or_output_iterator I, sentinel_for<I> S>
      constexpr iter_difference_t<I> distance(I first, S last);
    template<range R>
      constexpr range_difference_t<R> distance(R&& r);
 
    // ranges​::​next
    template<input_or_output_iterator I>
      constexpr I next(I x);
    template<input_or_output_iterator I>
      constexpr I next(I x, iter_difference_t<I> n);
    template<input_or_output_iterator I, sentinel_for<I> S>
      constexpr I next(I x, S bound);
    template<input_or_output_iterator I, sentinel_for<I> S>
      constexpr I next(I x, iter_difference_t<I> n, S bound);
 
    // ranges​::​prev
    template<bidirectional_iterator I>
      constexpr I prev(I x);
    template<bidirectional_iterator I>
      constexpr I prev(I x, iter_difference_t<I> n);
    template<bidirectional_iterator I>
      constexpr I prev(I x, iter_difference_t<I> n, I bound);
  }
 
  // 预定义迭代器与哨位
  // 逆向迭代器
  template<class Iter> class reverse_iterator;
 
  template<class Iter1, class Iter2>
    constexpr bool operator==(
      const reverse_iterator<Iter1>& x,
      const reverse_iterator<Iter2>& y);
  template<class Iter1, class Iter2>
    constexpr bool operator!=(
      const reverse_iterator<Iter1>& x,
      const reverse_iterator<Iter2>& y);
  template<class Iter1, class Iter2>
    constexpr bool operator<(
      const reverse_iterator<Iter1>& x,
      const reverse_iterator<Iter2>& y);
  template<class Iter1, class Iter2>
    constexpr bool operator>(
      const reverse_iterator<Iter1>& x,
      const reverse_iterator<Iter2>& y);
  template<class Iter1, class Iter2>
    constexpr bool operator<=(
      const reverse_iterator<Iter1>& x,
      const reverse_iterator<Iter2>& y);
  template<class Iter1, class Iter2>
    constexpr bool operator>=(
      const reverse_iterator<Iter1>& x,
      const reverse_iterator<Iter2>& y);
  template<class Iter1, three_way_comparable_with<Iter1> Iter2>
    constexpr compare_three_way_result_t<Iter1, Iter2>
      operator<=>(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
 
  template<class Iter1, class Iter2>
    constexpr auto operator-(
      const reverse_iterator<Iter1>& x,
      const reverse_iterator<Iter2>& y) -> decltype(y.base() - x.base());
  template<class Iter>
    constexpr reverse_iterator<Iter>
      operator+(
    typename reverse_iterator<Iter>::difference_type n,
    const reverse_iterator<Iter>& x);
 
  template<class Iter>
    constexpr reverse_iterator<Iter> make_reverse_iterator(Iter i);
 
  template<class Iter1, class Iter2>
      requires (!sized_sentinel_for<Iter1, Iter2>)
    inline constexpr bool disable_sized_sentinel<reverse_iterator<Iter1>,
                                                 reverse_iterator<Iter2>> = true;
 
  // 插入迭代器
  template<class Container> class back_insert_iterator;
  template<class Container>
    constexpr back_insert_iterator<Container> back_inserter(Container& x);
 
  template<class Container> class front_insert_iterator;
  template<class Container>
    constexpr front_insert_iterator<Container> front_inserter(Container& x);
 
  template<class Container> class insert_iterator;
  template<class Container>
    constexpr insert_iterator<Container>
      inserter(Container& x, ranges::iterator_t<Container> i);
 
  // 移动迭代器与哨位
  template<class Iter> class move_iterator;
 
  template<class Iter1, class Iter2>
    constexpr bool operator==(
      const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
  template<class Iter1, class Iter2>
    constexpr bool operator<(
      const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
  template<class Iter1, class Iter2>
    constexpr bool operator>(
      const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
  template<class Iter1, class Iter2>
    constexpr bool operator<=(
      const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
  template<class Iter1, class Iter2>
    constexpr bool operator>=(
      const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
  template<class Iter1, three_way_comparable_with<Iter1> Iter2>
    constexpr compare_three_way_result_t<Iter1, Iter2>
      operator<=>(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
 
  template<class Iter1, class Iter2>
    constexpr auto operator-(
    const move_iterator<Iter1>& x,
    const move_iterator<Iter2>& y) -> decltype(x.base() - y.base());
  template<class Iter>
    constexpr move_iterator<Iter> operator+(
      typename move_iterator<Iter>::difference_type n, const move_iterator<Iter>& x);
 
  template<class Iter>
    constexpr move_iterator<Iter> make_move_iterator(Iter i);
 
  template<semiregular S> class move_sentinel;
 
  // 公共迭代器
  template<input_or_output_iterator I, sentinel_for<I> S>
    requires (!same_as<I, S>)
      class common_iterator;
 
  template<class I, class S>
    struct incrementable_traits<common_iterator<I, S>>;
 
  template<input_iterator I, class S>
    struct iterator_traits<common_iterator<I, S>>;
 
  // 默认哨位
  struct default_sentinel_t;
  inline constexpr default_sentinel_t default_sentinel{};
 
  // 计数迭代器
  template<input_or_output_iterator I> class counted_iterator;
 
  template<class I>
    struct incrementable_traits<counted_iterator<I>>;
 
  template<input_iterator I>
    struct iterator_traits<counted_iterator<I>>;
 
  // 不可达哨位
  struct unreachable_sentinel_t;
  inline constexpr unreachable_sentinel_t unreachable_sentinel{};
 
  // 流迭代器
  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 = 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 = char_traits<charT>>
    class ostreambuf_iterator;
 
  // 范围访问
  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 (&a)[N]) noexcept;
  template<class T, size_t N> constexpr T* end(T (&a)[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 (&a)[N]);
  template<class T, size_t N> constexpr reverse_iterator<T*> rend(T (&a)[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));
 
  template<class C> constexpr auto size(const C& c) -> decltype(c.size());
  template<class T, size_t N> constexpr size_t size(const T (&a)[N]) noexcept;
  template<class C> constexpr auto ssize(const C& c)
    -> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>;
  template<class T, ptrdiff_t N> constexpr ptrdiff_t ssize(const T (&a)[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 (&a)[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 (&a)[N]) noexcept;
  template<class E> constexpr const E* data(initializer_list<E> il) noexcept;
}

概念 readable

namespace std {
  template<class In>
    concept readable =
      requires {
        typename iter_value_t<In>;
        typename iter_reference_t<In>;
        typename iter_rvalue_reference_t<In>;
      } &&
      common_reference_with<iter_reference_t<In>&&, iter_value_t<In>&> &&
      common_reference_with<iter_reference_t<In>&&, iter_rvalue_reference_t<In>&&> &&
      common_reference_with<iter_rvalue_reference_t<In>&&, const iter_value_t<In>&>;
}

概念 writable

namespace std {
  template<class Out, class T>
    concept writable =
      requires(Out&& o, T&& t) {
        *o = std::forward<T>(t); // 不要求保持相等性
        *std::forward<Out>(o) = std::forward<T>(t);
        // 不要求保持相等性
        const_cast<const iter_reference_t<Out>&&>(*o) =
        std::forward<T>(t); // 不要求保持相等性
        const_cast<const iter_reference_t<Out>&&>(*std::forward<Out>(o)) =
        std::forward<T>(t); // 不要求保持相等性
      };
}

概念 weakly_incrementable

namespace std {
  template<class T>
    inline constexpr bool __is_integer_like = /* 见描述 */; // 仅用于阐释
 
  template<class T>
    inline constexpr bool __is_signed_integer_like =  // 仅用于阐释
      /* 见描述 */;
 
  template<class I>
    concept weakly_incrementable =
      default_constructible<I> && movable<I> &&
      requires(I i) {
        typename iter_difference_t<I>;
        requires __is_signed_integer_like<iter_difference_t<I>>;
        { ++i } -> same_as<I&>;   // 不要求保持相等性
        i++;                      // 不要求保持相等性
      };
}

概念 incrementable

namespace std {
  template<class I>
    concept incrementable =
      regular<I> &&
      weakly_incrementable<I> &&
      requires(I i) {
        { i++ } -> same_as<I>;
      };
}

概念 input_or_output_iterator

namespace std {
  template<class I>
    concept input_or_output_iterator =
      requires(I i) {
        { *i } -> can-reference;
      } &&
      weakly_incrementable<I>;
}

概念 sentinel_for

namespace std {
  template<class S, class I>
    concept sentinel_for =
      semiregular<S> &&
      input_or_output_iterator<I> &&
      __WeaklyEqualityComparableWith<S, I>;
}

概念 sized_sentinel_for

namespace std {
  template<class S, class I>
    concept sized_sentinel_for =
      sentinel_for<S, I> &&
      !disable_sized_sentinel<remove_cv_t<S>, remove_cv_t<I>> &&
      requires(const I& i, const S& s) {
        { s - i } -> same_as<iter_difference_t<I>>;
        { i - s } -> same_as<iter_difference_t<I>>;
      };
}

概念 input_iterator

namespace std {
  template<class I>
    concept input_iterator =
      input_or_output_iterator<I> &&
      readable<I> &&
      requires { typename /*ITER_CONCEPT*/(I); } &&
      derived_from</*ITER_CONCEPT*/(I), input_iterator_tag>;
}

概念 output_iterator

namespace std {
  template<class I, class T>
    concept output_iterator =
      input_or_output_iterator<I> &&
      writable<I, T> &&
      requires(I i, T&& t) {
        *i++ = std::forward<T>(t); // 不要求保持相等性
      };
}

概念 forward_iterator

namespace std {
  template<class I>
    concept forward_iterator =
      input_iterator<I> &&
      derived_from</*ITER_CONCEPT*/(I), forward_iterator_tag> &&
      incrementable<I> &&
      sentinel_for<I, I>;
}

概念 bidirectional_iterator

namespace std {
  template<class I>
    concept bidirectional_iterator =
      forward_iterator<I> &&
      derived_from</*ITER_CONCEPT*/(I), bidirectional_iterator_tag> &&
      requires(I i) {
        { --i } -> same_as<I&>;
        { i-- } -> same_as<I>;
      };
}

概念 random_access_iterator

namespace std {
  template<class I>
    concept random_access_iterator =
      bidirectional_iterator<I> &&
      derived_from</*ITER_CONCEPT*/(I), random_access_iterator_tag> &&
      totally_ordered<I> &&
      sized_sentinel_for<I, I> &&
      requires(I i, const I j, const iter_difference_t<I> n) {
        { i += n } -> same_as<I&>;
        { j +  n } -> same_as<I>;
        { n +  j } -> same_as<I>;
        { i -= n } -> same_as<I&>;
        { j -  n } -> same_as<I>;
        {  j[n]  } -> same_as<iter_reference_t<I>>;
      };
}

概念 contiguous_iterator

namespace std {
  template<class I>
    concept contiguous_iterator =
      random_access_iterator<I> &&
      derived_from</*ITER_CONCEPT*/(I), contiguous_iterator_tag> &&
      is_lvalue_reference_v<iter_reference_t<I>> &&
      same_as<iter_value_t<I>, remove_cvref_t<iter_reference_t<I>>> &&
      requires(const I& i) {
        { to_address(i) } -> same_as<add_pointer_t<iter_reference_t<I>>>;
      };
}

概念 indirectly_unary_invocable

namespace std {
  template<class F, class I>
    concept indirectly_unary_invocable =
      readable<I> &&
      copy_constructible<F> &&
      invocable<F&, iter_value_t<I>&> &&
      invocable<F&, iter_reference_t<I>> &&
      invocable<F&, iter_common_reference_t<I>> &&
      common_reference_with<
        invoke_result_t<F&, iter_value_t<I>&>,
        invoke_result_t<F&, iter_reference_t<I>>>;
}

概念 indirectly_regular_unary_invocable

namespace std {
  template<class F, class I>
    concept indirectly_regular_unary_invocable =
      readable<I> &&
      copy_constructible<F> &&
      regular_invocable<F&, iter_value_t<I>&> &&
      regular_invocable<F&, iter_reference_t<I>> &&
      regular_invocable<F&, iter_common_reference_t<I>> &&
      common_reference_with<
        invoke_result_t<F&, iter_value_t<I>&>,
        invoke_result_t<F&, iter_reference_t<I>>>;
}

概念 indirect_unary_predicate

namespace std {
  template<class F, class I>
    concept indirect_unary_predicate =
      readable<I> &&
      copy_constructible<F> &&
      predicate<F&, iter_value_t<I>&> &&
      predicate<F&, iter_reference_t<I>> &&
      predicate<F&, iter_common_reference_t<I>>;
}

概念 indirect_relation

namespace std {
  template<class F, class I1, class I2 = I1>
    concept indirect_relation =
      readable<I1> && readable<I2> &&
      copy_constructible<F> &&
      relation<F&, iter_value_t<I1>&, iter_value_t<I2>&> &&
      relation<F&, iter_value_t<I1>&, iter_reference_t<I2>> &&
      relation<F&, iter_reference_t<I1>, iter_value_t<I2>&> &&
      relation<F&, iter_reference_t<I1>, iter_reference_t<I2>> &&
      relation<F&, iter_common_reference_t<I1>, iter_common_reference_t<I2>>;
}

概念 indirect_strict_weak_order

namespace std {
  template<class F, class I1, class I2 = I1>
    concept indirect_strict_weak_order =
      readable<I1> && readable<I2> &&
      copy_constructible<F> &&
      strict_weak_order<F&, iter_value_t<I1>&, iter_value_t<I2>&> &&
      strict_weak_order<F&, iter_value_t<I1>&, iter_reference_t<I2>> &&
      strict_weak_order<F&, iter_reference_t<I1>, iter_value_t<I2>&> &&
      strict_weak_order<F&, iter_reference_t<I1>, iter_reference_t<I2>> &&
      strict_weak_order<F&, iter_common_reference_t<I1>, iter_common_reference_t<I2>>;
}

概念 indirectly_movable

namespace std {
  template<class In, class Out>
    concept indirectly_movable =
      readable<In> &&
      writable<Out, iter_rvalue_reference_t<In>>;
}

概念 indirectly_movable_storable

namespace std {
  template<class In, class Out>
    concept indirectly_movable_storable =
      indirectly_movable<In, Out> &&
      writable<Out, iter_value_t<In>> &&
      movable<iter_value_t<In>> &&
      constructible_from<iter_value_t<In>, iter_rvalue_reference_t<In>> &&
      assignable_from<iter_value_t<In>&, iter_rvalue_reference_t<In>>;
}

概念 indirectly_copyable

namespace std {
  template<class In, class Out>
    concept indirectly_copyable =
      readable<In> &&
      writable<Out, iter_reference_t<In>>;
}

概念 indirectly_copyable_storable

namespace std {
  template<class In, class Out>
    concept indirectly_copyable_storable =
      indirectly_copyable<In, Out> &&
      writable<Out, const iter_value_t<In>&> &&
      copyable<iter_value_t<In>> &&
      constructible_from<iter_value_t<In>, iter_reference_t<In>> &&
      assignable_from<iter_value_t<In>&, iter_reference_t<In>>;
}

概念 indirectly_swappable

namespace std {
  template<class I1, class I2 = I1>
    concept indirectly_swappable =
      readable<I1> && readable<I2> &&
      requires(I1& i1, I2& i2) {
        ranges::iter_swap(i1, i1);
        ranges::iter_swap(i2, i2);
        ranges::iter_swap(i1, i2);
        ranges::iter_swap(i2, i1);
      };
}

概念 indirectly_comparable

namespace std {
  template<class I1, class I2, class R, class P1 = identity, class P2 = identity>
    concept indirectly_comparable =
      indirect_relation<R, projected<I1, P1>, projected<I2, P2>>;
}

概念 permutable

namespace std {
  template<class I>
    concept permutable =
      forward_iterator<I> &&
      indirectly_movable_storable<I, I> &&
      indirectly_swappable<I, I>;
}

概念 mergeable

namespace std {
  template<class I1, class I2, class Out, class R = ranges::less,
           class P1 = identity, class P2 = identity>
    concept mergeable =
      input_iterator<I1> &&
      input_iterator<I2> &&
      weakly_incrementable<Out> &&
      indirectly_copyable<I1, Out> &&
      indirectly_copyable<I2, Out> &&
      indirect_strict_weak_order<R, projected<I1, P1>, projected<I2, P2>>;
}

概念 sortable

namespace std {
  template<class I, class R = ranges::less, class P = identity>
    concept sortable =
      permutable<I> &&
      indirect_strict_weak_order<R, projected<I, P>>;
}

类模板 std::incrementable_traits

namespace std {
  template<class> struct incrementable_traits { };
 
  template<class T>
    requires is_object_v<T>
  struct incrementable_traits<T*> {
    using difference_type = ptrdiff_t;
  };
 
  template<class I>
  struct incrementable_traits<const I>
    : incrementable_traits<I> { };
 
  template<class T>
    requires requires { typename T::difference_type; }
  struct incrementable_traits<T> {
    using difference_type = typename T::difference_type;
  };
 
  template<class T>
    requires (!requires { typename T::difference_type; } &&
              requires(const T& a, const T& b) { { a - b } -> integral; })
  struct incrementable_traits<T> {
    using difference_type = make_signed_t<decltype(declval<T>() - declval<T>())>;
  };
 
  template<class T>
    using iter_difference_t = /* 见描述 */;
}

类模板 std::readable_traits

namespace std {
  template<class> struct __cond_value_type { };   // 仅用于阐释
  template<class T>
    requires is_object_v<T>
  struct __cond_value_type {
    using value_type = remove_cv_t<T>;
  };
 
  template<class> struct readable_traits { };
 
  template<class T>
  struct readable_traits<T*>
    : __cond_value_type<T> { };
 
  template<class I>
    requires is_array_v<I>
  struct readable_traits<I> {
    using value_type = remove_cv_t<remove_extent_t<I>>;
  };
 
  template<class I>
  struct readable_traits<const I>
    : readable_traits<I> { };
 
  template<class T>
    requires requires { typename T::value_type; }
  struct readable_traits<T>
    : __cond_value_type<typename T::value_type> { };
 
  template<class T>
    requires requires { typename T::element_type; }
  struct readable_traits<T>
    : __cond_value_type<typename T::element_type> { };
}

类模板 std::projected

namespace std {
  template<readable I, indirectly_regular_unary_invocable<I> Proj>
  struct projected {
    using value_type = remove_cvref_t<indirect_result_t<Proj&, I>>;
    indirect_result_t<Proj&, I> operator*() const; // 不定义
  };
 
  template<weakly_incrementable I, class Proj>
  struct incrementable_traits<projected<I, Proj>> {
    using difference_type = iter_difference_t<I>;
  };
}

类模板 std::iterator_traits

namespace std {
  template<class I>
  struct iterator_traits {
    using iterator_category = /* 见描述 */;
    using value_type        = /* 见描述 */;
    using difference_type   = /* 见描述 */;
    using pointer           = /* 见描述 */;
    using reference         = /* 见描述 */;
  };
 
  template<class T>
    requires is_object_v<T>
  struct iterator_traits<T*> {
    using iterator_concept  = contiguous_iterator_tag;
    using iterator_category = random_access_iterator_tag;
    using value_type        = remove_cv_t<T>;
    using difference_type   = ptrdiff_t;
    using pointer           = T*;
    using reference         = T&;
  };
}

迭代器标签

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 { };
  struct contiguous_iterator_tag: public random_access_iterator_tag { };
}

类模板 std::reverse_iterator

namespace std {
  template<class Iter>
  class reverse_iterator {
  public:
    using iterator_type     = Iter;
    using iterator_concept  = /* 见描述 */;
    using iterator_category = /* 见描述 */;
    using value_type        = iter_value_t<Iter>;
    using difference_type   = iter_difference_t<Iter>;
    using pointer           = typename iterator_traits<Iter>::pointer;
    using reference         = iter_reference_t<Iter>;
 
    constexpr reverse_iterator();
    constexpr explicit reverse_iterator(Iter 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 Iter base() const;
    constexpr reference operator*() const;
    constexpr pointer   operator->() const requires /* 见描述 */;
 
    constexpr reverse_iterator& operator++();
    constexpr reverse_iterator  operator++(int);
    constexpr reverse_iterator& operator--();
    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 /* 未指明 */ operator[](difference_type n) const;
 
    friend constexpr iter_rvalue_reference_t<Iter>
      iter_move(const reverse_iterator& i) noexcept(/* 见描述 */);
    template<indirectly_swappable<Iter> Iter2>
      friend constexpr void
        iter_swap(const reverse_iterator& x,
                  const reverse_iterator<Iter2>& y) noexcept(/* 见描述 */);
 
  protected:
    Iter current;
  };
}

类模板 std::back_insert_iterator

namespace std {
  template<class Container>
  class back_insert_iterator {
  protected:
    Container* container = nullptr;
 
  public:
    using iterator_category = output_iterator_tag;
    using value_type        = void;
    using difference_type   = ptrdiff_t;
    using pointer           = void;
    using reference         = void;
    using container_type    = Container;
 
    constexpr back_insert_iterator() noexcept = default;
    constexpr explicit back_insert_iterator(Container& x);
    constexpr back_insert_iterator& operator=(const typename Container::value_type& value);
    constexpr back_insert_iterator& operator=(typename Container::value_type&& value);
 
    constexpr back_insert_iterator& operator*();
    constexpr back_insert_iterator& operator++();
    constexpr back_insert_iterator  operator++(int);
  };
}

类模板 std::front_insert_iterator

namespace std {
  template<class Container>
  class front_insert_iterator {
  protected:
    Container* container = nullptr;
 
  public:
    using iterator_category = output_iterator_tag;
    using value_type        = void;
    using difference_type   = ptrdiff_t;
    using pointer           = void;
    using reference         = void;
    using container_type    = Container;
 
    constexpr front_insert_iterator(Container& x) noexcept = default;
    constexpr explicit front_insert_iterator(Container& x);
    constexpr front_insert_iterator&
      operator=(const typename Container::value_type& value);
    constexpr front_insert_iterator& operator=(typename Container::value_type&& value);
 
    constexpr front_insert_iterator& operator*();
    constexpr front_insert_iterator& operator++();
    constexpr front_insert_iterator  operator++(int);
  };
}

类模板 std::insert_iterator

namespace std {
  template<class Container>
  class insert_iterator {
  protected:
    Container* container = nullptr;
    ranges::iterator_t<Container> iter = ranges::iterator_t<Container>();
 
  public:
    using iterator_category = output_iterator_tag;
    using value_type        = void;
    using difference_type   = ptrdiff_t;
    using pointer           = void;
    using reference         = void;
    using container_type    = Container;
 
    insert_iterator() = default;
    constexpr insert_iterator(Container& x, ranges::iterator_t<Container> i);
    constexpr insert_iterator& operator=(const typename Container::value_type& value);
    constexpr insert_iterator& operator=(typename Container::value_type&& value);
 
    constexpr insert_iterator& operator*();
    constexpr insert_iterator& operator++();
    constexpr insert_iterator& operator++(int);
  };
}

类模板 std::move_iterator

namespace std {
  template<class Iter>
  class move_iterator {
  public:
    using iterator_type     = Iter;
    using iterator_concept  = input_iterator_tag;
    using iterator_category = /* 见描述 */;
    using value_type        = iter_value_t<Iter>;
    using difference_type   = iter_difference_t<Iter>;
    using pointer           = Iter;
    using reference         = iter_rvalue_reference_t<Iter>;
 
    constexpr move_iterator();
    constexpr explicit move_iterator(Iter 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 iterator_type base() &&;
    constexpr reference operator*() const;
    constexpr pointer operator->() const;
 
    constexpr move_iterator& operator++();
    constexpr auto 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 reference operator[](difference_type n) const;
 
    template<sentinel_for<Iter> S>
      friend constexpr bool
        operator==(const move_iterator& x, const move_sentinel<S>& y);
    template<sized_sentinel_for<Iter> S>
      friend constexpr iter_difference_t<Iter>
        operator-(const move_sentinel<S>& x, const move_iterator& y);
    template<sized_sentinel_for<Iter> S>
      friend constexpr iter_difference_t<Iter>
        operator-(const move_iterator& x, const move_sentinel<S>& y);
    friend constexpr iter_rvalue_reference_t<Iter>
      iter_move(const move_iterator& i)
        noexcept(noexcept(ranges::iter_move(i.current)));
    template<indirectly_swappable<Iter> Iter2>
      friend constexpr void
        iter_swap(const move_iterator& x, const move_iterator<Iter2>& y)
          noexcept(noexcept(ranges::iter_swap(x.current, y.current)));
 
  private:
    Iter current;     // 仅用于阐释
  };
}

类模板 std::move_sentinel

namespace std {
  template<semiregular S>
  class move_sentinel {
  public:
    constexpr move_sentinel();
    constexpr explicit move_sentinel(S s);
    template<class S2>
      requires convertible_to<const S2&, S>
        constexpr move_sentinel(const move_sentinel<S2>& s);
    template<class S2>
      requires assignable_from<S&, const S2&>
        constexpr move_sentinel& operator=(const move_sentinel<S2>& s);
 
    constexpr S base() const;
  private:
    S last;     // 仅用于阐释
  };
}

类模板 std::common_iterator

namespace std {
  template<input_or_output_iterator I, sentinel_for<I> S>
    requires (!same_as<I, S>)
  class common_iterator {
  public:
    constexpr common_iterator() = default;
    constexpr common_iterator(I i);
    constexpr common_iterator(S s);
    template<class I2, class S2>
      requires convertible_to<const I2&, I> && convertible_to<const S2&, S>
        constexpr common_iterator(const common_iterator<I2, S2>& x);
 
    template<class I2, class S2>
      requires convertible_to<const I2&, I> && convertible_to<const S2&, S> &&
               assignable_from<I&, const I2&> && assignable_from<S&, const S2&>
        common_iterator& operator=(const common_iterator<I2, S2>& x);
 
    decltype(auto) operator*();
    decltype(auto) operator*() const
      requires dereferenceable<const I>;
    decltype(auto) operator->() const
      requires /* 见描述 */;
 
    common_iterator& operator++();
    decltype(auto) operator++(int);
 
    template<class I2, sentinel_for<I> S2>
      requires sentinel_for<S, I2>
    friend bool operator==(
      const common_iterator& x, const common_iterator<I2, S2>& y);
    template<class I2, sentinel_for<I> S2>
      requires sentinel_for<S, I2> && equality_comparable_with<I, I2>
    friend bool operator==(
      const common_iterator& x, const common_iterator<I2, S2>& y);
 
    template<sized_sentinel_for<I> I2, sized_sentinel_for<I> S2>
      requires sized_sentinel_for<S, I2>
    friend iter_difference_t<I2> operator-(
      const common_iterator& x, const common_iterator<I2, S2>& y);
 
    friend iter_rvalue_reference_t<I> iter_move(const common_iterator& i)
      noexcept(noexcept(ranges::iter_move(declval<const I&>())))
        requires input_iterator<I>;
    template<indirectly_swappable<I> I2, class S2>
      friend void iter_swap(const common_iterator& x, const common_iterator<I2, S2>& y)
        noexcept(noexcept(ranges::iter_swap(declval<const I&>(), declval<const I2&>())));
 
  private:
    variant<I, S> v_;   // 仅用于阐释
  };
 
  template<class I, class S>
  struct incrementable_traits<common_iterator<I, S>> {
    using difference_type = iter_difference_t<I>;
  };
 
  template<input_iterator I, class S>
  struct iterator_traits<common_iterator<I, S>> {
    using iterator_concept = /* 见描述 */;
    using iterator_category = /* 见描述 */;
    using value_type = iter_value_t<I>;
    using difference_type = iter_difference_t<I>;
    using pointer = /* 见描述 */;
    using reference = iter_reference_t<I>;
  };
}

std::default_sentinel_t

namespace std {
  struct default_sentinel_t { };
}

类模板 std::counted_iterator

namespace std {
  template<input_or_output_iterator I>
  class counted_iterator {
  public:
    using iterator_type = I;
 
    constexpr counted_iterator() = default;
    constexpr counted_iterator(I x, iter_difference_t<I> n);
    template<class I2>
      requires convertible_to<const I2&, I>
        constexpr counted_iterator(const counted_iterator<I2>& x);
 
    template<class I2>
      requires assignable_from<I&, const I2&>
        constexpr counted_iterator& operator=(const counted_iterator<I2>& x);
 
    constexpr I base() const & requires copy_constructible<I>;
    constexpr I base() &&;
    constexpr iter_difference_t<I> count() const noexcept;
    constexpr decltype(auto) operator*();
    constexpr decltype(auto) operator*() const
      requires dereferenceable<const I>;
 
    constexpr counted_iterator& operator++();
    decltype(auto) operator++(int);
    constexpr counted_iterator operator++(int)
      requires forward_iterator<I>;
    constexpr counted_iterator& operator--()
      requires bidirectional_iterator<I>;
    constexpr counted_iterator operator--(int)
      requires bidirectional_iterator<I>;
 
    constexpr counted_iterator operator+(iter_difference_t<I> n) const
      requires random_access_iterator<I>;
    friend constexpr counted_iterator operator+(
      iter_difference_t<I> n, const counted_iterator& x)
        requires random_access_iterator<I>;
    constexpr counted_iterator& operator+=(iter_difference_t<I> n)
      requires random_access_iterator<I>;
 
    constexpr counted_iterator operator-(iter_difference_t<I> n) const
      requires random_access_iterator<I>;
    template<common_with<I> I2>
      friend constexpr iter_difference_t<I2> operator-(
        const counted_iterator& x, const counted_iterator<I2>& y);
    friend constexpr iter_difference_t<I> operator-(
      const counted_iterator& x, default_sentinel_t);
    friend constexpr iter_difference_t<I> operator-(
      default_sentinel_t, const counted_iterator& y);
    constexpr counted_iterator& operator-=(iter_difference_t<I> n)
      requires random_access_iterator<I>;
 
    constexpr decltype(auto) operator[](iter_difference_t<I> n) const
      requires random_access_iterator<I>;
 
    template<common_with<I> I2>
      friend constexpr bool operator==(
        const counted_iterator& x, const counted_iterator<I2>& y);
    friend constexpr bool operator==(
      const counted_iterator& x, default_sentinel_t);
 
    template<common_with<I> I2>
      friend constexpr strong_ordering operator<=>(
        const counted_iterator& x, const counted_iterator<I2>& y);
 
    friend constexpr iter_rvalue_reference_t<I> iter_move(const counted_iterator& i)
      noexcept(noexcept(ranges::iter_move(i.current)))
        requires input_iterator<I>;
    template<indirectly_swappable<I> I2>
      friend constexpr void iter_swap(const counted_iterator& x,
                                      const counted_iterator<I2>& y)
        noexcept(noexcept(ranges::iter_swap(x.current, y.current)));
 
  private:
    I current = I();                    // 仅用于阐释
    iter_difference_t<I> length = 0;    // 仅用于阐释
  };
 
  template<class I>
  struct incrementable_traits<counted_iterator<I>> {
    using difference_type = iter_difference_t<I>;
  };
 
  template<input_iterator I>
  struct iterator_traits<counted_iterator<I>> : iterator_traits<I> {
    using pointer = void;
  };
}

std::unreachable_sentinel_t

namespace std {
  struct unreachable_sentinel_t {
    template<weakly_incrementable I>
      friend constexpr bool operator==(unreachable_sentinel_t, const I&) noexcept
      { return false; }
  };
}

类模板 std::istream_iterator

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();
    constexpr istream_iterator(default_sentinel_t);
    istream_iterator(istream_type& s);
    istream_iterator(const istream_iterator& x) = default;
    ~istream_iterator() = default;
    istream_iterator& operator=(const istream_iterator&) = default;
 
    const T& operator*() const;
    const T* operator->() const;
    istream_iterator& operator++();
    istream_iterator  operator++(int);
 
    friend bool operator==(const istream_iterator& i, default_sentinel_t);
 
  private:
    basic_istream<CharT, Traits>* in_stream; // 仅用于阐释
    T value;                                 // 仅用于阐释
  };
}

类模板 std::ostream_iterator

namespace std {
  template<class T, class CharT = char, classTraits = char_traits<CharT>>
  class ostream_iterator {
  public:
    using iterator_category = output_iterator_tag;
    using value_type        = void;
    using difference_type   = ptrdiff_t;
    using pointer           = void;
    using reference         = void;
    using char_type         = CharT;
    using traits_type       = Traits;
    using ostream_type      = basic_ostream<CharT, Traits>;
 
    constexpr ostreambuf_iterator() noexcept = default;
    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 ostream_iterator&) = default;
    ostream_iterator& operator=(const T& value);
 
    ostream_iterator& operator*();
    ostream_iterator& operator++();
    ostream_iterator& operator++(int);
 
  private:
    basic_ostream<CharT, Traits>* out_stream = nullptr;          // 仅用于阐释
    const CharT* delim = nullptr;                                // 仅用于阐释
  };
}

类模板 std::istreambuf_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           = /* 未指明 */;
    using reference         = CharT;
    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;                          // 仅用于阐释
 
    constexpr istreambuf_iterator() noexcept;
    constexpr istreambuf_iterator(default_sentinel_t) 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;
    istreambuf_iterator& operator=(const istreambuf_iterator&) noexcept = default;
    CharT operator*() const;
    istreambuf_iterator& operator++();
    proxy operator++(int);
    bool equal(const istreambuf_iterator& b) const;
 
    friend bool operator==(const istreambuf_iterator& i, default_sentinel_t s);
 
  private:
    streambuf_type* sbuf_;                // 仅用于阐释
  };
 
  template<class CharT, class Traits>
  class istreambuf_iterator<CharT, Traits>::proxy { // 仅用于阐释
    CharT keep_;
    basic_streambuf<CharT, Traits>* sbuf_;
    proxy(CharT c, basic_streambuf<CharT, Traits>* sbuf)
      : keep_(c), sbuf_(sbuf) { }
  public:
    CharT operator*() { return keep_; }
  };
}

类模板 std::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   = ptrdiff_t;
    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>;
 
    constexpr ostreambuf_iterator() noexcept = default;
    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_ = nullptr;    // 仅用于阐释
  };
}

类模板 std::iterator

namespace std {
  template<class Category, class T, class Distance = ptrdiff_t,
           class Pointer = T*, class Reference = T&>
  struct iterator {
    typedef Category  iterator_category;
    typedef T         value_type;
    typedef Distance  difference_type;
    typedef Pointer   pointer;
    typedef Reference reference;
  };
}