Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Concept OutputIterator 輸出迭代器概念

OutputIterator 輸出迭代器

Description 說明

An output iterator is an iterator that can write a sequence of values. It is single-pass (old values of the iterator cannot be re-used), and write-only. 
輸出迭代器是一種可以寫出一組值的序列的迭代器。它是單遍的(迭代器的舊值不可重用)和只寫的。

An output iterator represents a position in a (possibly infinite) sequence. Therefore, the iterator can point into the sequence (returning a value when dereferenced and being incrementable), or be off-the-end (and not dereferenceable or incrementable). 
輸出迭代器表示了在一個序列(可能是無限的)中的某個位置。因此,迭代器可以指向序列內部(在提領時返回一個值且可以遞增),或者指向序列末端之後(不可提領且不可遞 增)

Associated types 關聯類型

  • value_type

    std::iterator_traits<Iter>::value_type

    The stated value type of the iterator (should be void for an output iterator that does not model some other iterator concept).
    迭代器聲明的值類型(對於不符合其它迭代器概念的輸出迭代器,可以為 void)

  • difference_type

    std::iterator_traits<Iter>::difference_type

    The difference type of the iterator
    迭代器的距離類型

  • category

    std::iterator_traits<Iter>::iterator_category

    The category of the iterator
    迭代器的類別

Notation 符號

Iter
A type playing the role of iterator-type in the OutputIterator concept.
輸出迭代器 概念中擔任迭代器類型角色的類型。
ValueType
A type playing the role of value-type in the OutputIterator concept.
輸出迭代器 概念中擔任值類型角色的類型。
i, j
Objects of type Iter
類型 Iter 的對象
x
Object of type ValueType
類型 ValueType 的對象

Type expressions 類型表達式

The type Iter must be a model of Assignable.

類型 Iter 必須為 可賦值

The type ValueType must be a model of Assignable.

類型 ValueType 必須為 可賦值

The type Iter must be a model of DefaultConstructible.

類型 Iter 必須為 可缺省構造

The type Iter must be a model of EqualityComparable.

類型 Iter 必須為 可等價比較

Category tag 類別標記

category must be derived from std::output_iterator_tag, a model of DefaultConstructible, and a model of CopyConstructible.

category 必須派生自 std::output_iterator_tag,且 可缺省構造可複製構造

Difference type properties 距離類型屬性

difference_type must be a model of SignedInteger.

difference_type 必須為 有符號整數

Valid expressions 有效表達式

Name 名字 Expression 表達式 Type 類型 Precondition 前置條件 Semantics 語義 Postcondition 後置條件

Dereference 提領

*i

i is incrementable (not off-the-end)
i 是可遞增的(不是 off-the-end)

   

Dereference and assign 

提領並賦值

*i = x

i is incrementable (not off-the-end)
i 是可遞增的(不是 off-the-end)

 

*i may not be written to again until it has been incremented.

*i 可能是不可寫的,直至被遞增後

Preincrement 前緣遞增

++i

Iter &

i is incrementable (not off-the-end)
i 是可遞增的(不是 off-the-end)

   

Postincrement 後綴遞增

i++

i is incrementable (not off-the-end)
i 是可遞增的(不是 off-the-end)

Equivalent to (void)(++i)

等價於 (void)(++i)

i is dereferenceable or off-the-end
i 為可提領的或 off-the-end

Postincrement, dereference, and assign

後綴遞增、提領並賦值

*i++ = x

i is incrementable (not off-the-end)
i 是可遞增的(不是 off-the-end)

Equivalent to {*i = t; ++i;}

等價於 {*i = t; ++i;}

i is dereferenceable or off-the-end
i 為可提領的或 off-the-end

Complexity 複雜度

All iterator operations must take amortized constant time.
迭代器的所有操作必須為分期常量時間複雜度。

Models 模型

  • std::ostream_iterator, ...
  • std::insert_iterator, ...
  • std::front_insert_iterator, ...
  • std::back_insert_iterator, ...

PrevUpHomeNext