Boost logo

Boost :

From: Jason Turner (lefticus_at_[hidden])
Date: 2007-03-06 19:33:26


On 3/6/07, Steven Watanabe <steven_at_[hidden]> wrote:
> AMDG
>
> Jason Turner <lefticus <at> gmail.com> writes:
>
> > <snip>
> >
>
> You should not store a pointer you should store
> a value. If users need a pointer then they
> can specify it explicitly.
>
> active_object::active_object<TestClass> ao;
>

I agree, in principal, and it was my original intention. However, a
design goal was to make sure that any existing class could work with
active_object and your above example does not allow for a specific
constructor to be called. I guess, however, now that I think about it,
if the user needs to call the not-default constructor he can store a
pointer.

> The << operator is not appropriate. A function is better
>
> ao.execute(boost::function1<int,TestClass *>(&TestClass::getInt));
>
> You could use operator() but that might still be
> confusing.
>
> ao(boost::function1<int,TestClass *>(&TestClass::getInt));
>
> Ideally you want
>
> a0->getInt();
>
> But this is not possible. Another possibility is
>
> (ao->*&TestClass::getInt)();
>

I also considered something along the lines of:

ao->(&TestClass::getInt);

What is your thought on that?

> In Christ,
> Steven Watanabe

-Jason


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