If knowledge can create problems, it is not through ignorance that we can solve them.
As was discussed in the last chapter,
std::ostream_iterator supports the required semantics of an output iterator by using a simple implementation trick, whereby the dereference operator (
operator *()) returns an instance to the object and an assignment operator (
operator =()) taking the assigned type is defined. (See Listing 34.5 to see how it is implemented for
stlsoft::ostream_iterator.) Consider the following code:
1 std::ostream_iterator<int> iter(std::cout); 2 3 *iter = 10; // Sensible
Line 3 is equivalent to:
iter.operator *().operator =(10); ...