Difference between revisions of "cpp/named req/OutputIterator"
From cppreference.com
(added link) |
(a little text to clarify things) |
||
Line 4: | Line 4: | ||
An {{tt|OutputIterator}} is an {{concept|Iterator}} that can write to the pointed-to element. | An {{tt|OutputIterator}} is an {{concept|Iterator}} that can write to the pointed-to element. | ||
− | An example of a | + | An example of a type that implements {{tt|OutputIterator}} is [[cpp/iterator/ostream_iterator|std::ostream_iterator]]. |
===Requirements=== | ===Requirements=== | ||
+ | |||
+ | For a type {{tt|It}} to meet the {{tt|OutputIterator}} requirements, it must satisfy the following concepts: | ||
+ | |||
* {{concept|Iterator}} | * {{concept|Iterator}} | ||
+ | |||
+ | In addition, instances {{tt|i}} and {{tt|o}} of type {{tt|It}} must support the following operations: | ||
{|table class="wikitable" | {|table class="wikitable" | ||
Line 16: | Line 21: | ||
|- | |- | ||
|{{c|++i}}||{{c|It&}}|| | |{{c|++i}}||{{c|It&}}|| | ||
− | |After this, copies of {{ttb| | + | |After this, copies of {{ttb|i}} may be invalidated.<br> |
'''Post''': {{c|&r {{==}} &++r}} | '''Post''': {{c|&r {{==}} &++r}} | ||
|- | |- |
Revision as of 14:19, 23 May 2012
Template:cpp/concept/title Template:cpp/concept/sidebar
An OutputIterator
is an Template:concept that can write to the pointed-to element.
An example of a type that implements OutputIterator
is std::ostream_iterator.
Requirements
For a type It
to meet the OutputIterator
requirements, it must satisfy the following concepts:
In addition, instances i
and o
of type It
must support the following operations:
Expression | Return | Equivalent expression | Notes |
---|---|---|---|
*i = o | it may not be possible to write twice in the same iterator | ||
++i | It& | After this, copies of i may be invalidated.Post: &r == &++r | |
i++ | const It& | It temp = i; ++i; |
|
*i++ = o | *i = o; ++i; |