Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2001-07-11 06:45:30


On Wednesday 11 July 2001 05:56, you wrote:
> > -----Original Message-----
> > From: Douglas Gregor [mailto:gregod_at_[hidden]]
> > Sent: 10 July 2001 02:31
> > To: boost_at_[hidden]
> > Subject: Re: [boost] boost::function
> >
> > On Monday 09 July 2001 06:58, you wrote:
> > > I'm playing with the boost:: function library for the first
> >
> > time, probably
> >
> > > a naive question but, could someone explain to me why the mixins and
> > > policies classes are expected to be stateless i.e. always default
> > > constructed?
> >
> > Always default constructed and stateless are two different things.
>
> Yes, I didn't express myself very well.
>
> > Mixins add user-defined state. They are default-constructed because this
> > appears to be common practice for mixins; however, it would be a
> > small matter
> > to include the ability for the user to specify an initial value.
>
> I was thinking more along the lines that the mixin should be copy
> constructed,
> whenever the function object is, and leave it to the mixin to determine
> what copying means.
>
> Regardless, should not the swap function also swap the mixins?

Yes, it should.

> I modified the source to implement both with no problems.

If you would like to send a patch I'll integrate it.

> > Policy classes aren't entirely stateless. They retain state over one
> > invocation of a Boost.Function object (i.e., the same policy
> > object will have
> > its precall and postcall methods invoked for a single invocation of the
> > Boost.Function object), but they do not retain state between invocations.
> > Policies are default-constructed because there doesn't appear to be any
> > useful information to pass to the policy constructor.
>
> Yes, makes sense to me ;-)
>
> Thanks
>
> Richard

        Doug


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