OTL 4.0, STL-compliant output iterator

STL-compliant output iterator

otl_output_iterator<T>

Category: iterators Component type: type

Description

otl_output_iterator is an Output Iterator that performs output of objects of type T to a particular otl_stream. Note that all of the restrictions of an Output Iterator must be obeyed, including the restrictions on the ordering of operator* and operator++ operations.

Definition

Defined in the OTL header file..

Template parameters

Parameter  Description  Default 
T The type of object that will be written to the otl_stream. The set of value types of an otl_output_iterator consists of a single type, T  

Model of

Output Iterator.

Type requirements

T must be a type such that otl_stream s;...; s << T is a valid expression.

Public base classes

None.

Members

Member  Where defined  Description 
otl_output_iterator(otl_stream&) otl_output_iterator See below. 
otl_output_iterator(const otl_output_iterator&) Output Iterator The copy constructor 
otl_output_iterator& operator=(const otl_output_iterator&) Output Iterator The assignment operator 
otl_output_iterator& operator=(const T&) Output Iterator Used to implement the Output Iterator requirement *i = t. [1]
otl_output_iterator& operator*() Output Iterator Used to implement the Output Iterator requirement *i = t. [1]
otl_output_iterator& operator++() Output Iterator Preincrement 
otl_output_iterator& operator++(int) Output Iterator Postincrement 
output_iterator_tag iterator_category(const otl_output_iterator&) iterator tags Returns the iterator's category. 

New members

These members are not defined in the Output Iterator requirements, but are specific to otl_output_iterator.
 
Function  Description 
otl_output_iterator(otl_stream& s) Creates an otl_output_iterator such that assignment of t through it is equivalent to s << t

Notes

[1] Note how assignment through an otl_output_iterator is implemented. In general, unary operator* must be defined so that it returns a proxy object, where the proxy object defines operator= to perform the output operation. In this case, for the sake of simplicity, the proxy object is the otl_output_iterator itself. That is, *i simply returns i, and *i = t is equivalent to i = t. You should not, however, rely on this behavior. It is an implementation detail, and it is not guaranteed to remain the same in future versions.

See also

otl_input_iterator, Output Iterator, Input Iterator.


Contents Go Home

Copyright © 1996-2017, Sergei Kuchin, email: skuchin@gmail.com, skuchin@gmail.com

Permission to use, copy, modify and redistribute this document for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.