Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-06-13 06:22:25


David Abrahams wrote:
> The interface to output_iterator_helper needs to be changed anyway, to
> remove all of those parameters which default to void (an
> output iterator /must/ have void value_type and differnce_type anyway).

Talking about interface changes - how about this:

template<class Derived>
struct output_iterator_helper
  : boost::incrementable<Derived
  , boost::iterator<std::output_iterator_tag, void, void, void, void
> >
  {
  Derived& operator*() { return static_cast<Derived&>(*this); }
  Derived& operator++() { return static_cast<Derived&>(*this); }
  };

Self-proxing is the most common and easy way to implement output iterators,
and IMO it would be reasonable for 'output_iterator_helper' to provide a
default support for the idiom, if this does not prevent other usages. AFAIK,
the above form doesn't. Basically, it's what we are using here at work, and
I would love to replace it by the boost code instead :).

Aleksey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk