|
Boost : |
From: Richard Crossley (rcrossley_at_[hidden])
Date: 2001-07-11 04:56:15
> -----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?
I modified the source to implement both with no problems.
> 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk