Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-25 07:46:39

----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>

> > - so, for example, writing something like
> > this:
> >
> > boost::make_filter_iterator(
> > views.begin()
> > , views.end()
> > , boost::bind<bool>(std::logical_and<bool>()
> > , boost::bind(&view::is_visible, _1)
> > , boost::bind(&view::contains, _1, point)
> > ) // the predicate is not assignable
> > )
> >
> > is pretty much useless, as the expression returns an iterator object
> is
> > not assignable - i.e. something that is not an iterator at all, at least
> not
> > the one that you can use with the standard library algorithms.
> This is an interesting example. The filter iterator stores a copy of the
> function object.
> What immediately comes to mind is, isn't it possible to make the iterator
> hold a shared_ptr<Predicate> instead? This solves the Assignable problem
> and, in general, refcounting the function object is better in cases where
> it's stateful.

Yeah, but makes the iterator a /lot/ heavier in the case where it's not
stateful. I would want to have the user pass us the appropriate
boost::function<>, or such like, when it's stateful. That's not a change I
would want to make users pay for.

> > As for 'boost::reference_wrapper<>', here is a proposed modification to
> make
> > it meet Assignable requirement (rather simple one, I admit :):
> I don't know. ref() is supposed to model a reference, and references
> reseatable; but, OTOH, I don't have any solid technical (as opposed to
> conceptual) argument against the change.

It's supposed to model a reference without some of the limitations: e.g.,
you can pass it through a function template without losing its referential
qualities. In any case, its modelling of reference is woefully incomplete
(for example, if you assign to a reference it modifies the referent; there
might be arithmetic opertors, etc.) FWIW, the reference_wrapper I had been u
sing for some time now uses Aleksey's implementation, and I would like it
very much if he made the change he's proposing.

However, the final decision rests with Peter, I guess...



Boost list run by bdawes at, gregod at, cpdaniel at, john at