iterator Struct

用于的空白基本结构确保用户定义的迭代器类用于 iterator_traits. 一起使用。

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

备注

模板结构作为一个基础所有迭代器。 它定义成员类型

  • iterator_category (模板参数的 Category) 同义词。

  • value_type (模板参数的 类型) 同义词。

  • difference_type (模板参数的 Distance) 同义词。

  • distance_type (模板参数的 Distance) 同义词

  • pointer (模板参数的 Pointer) 同义词。

  • reference (模板参数的 Reference) 同义词。

请注意 value_type 不应为常数的类型,即使 指针 点对常数 类型 对象和引用指定 const 类型对象。

示例

为的示例演示如何参见 iterator_traits 声明和使用类型在迭代器基类。

要求

标题: iterator

命名空间: std

请参见

参考

<iterator>

线程安全性对标准C++库中

标准模板库