Boost logo

Boost :

From: Marco Costalba (mcostalba_at_[hidden])
Date: 2008-05-15 17:59:04


On Thu, May 15, 2008 at 8:36 PM, Daniel Walker
<daniel.j.walker_at_[hidden]> wrote:
>
> Yes, so long as the copy constructor of the wrapped function object
> maintains internal_state.

If the copy c'tor copies the internal state then what's the difference between:

function<float(float,float)> add_floats = plus();

add_floats.target<plus>()->internal_state = 7;

function<int(int,int)> f0 = functional_cast<plus(int,int)>(add_floats);

std::cout << f0.internal_state; // it's 7 !

And

function<float(float,float)> add_floats = plus();

add_floats.target<plus>()->internal_state = 7;

plus tmp( *add_floats.target<plus>() ); // copy c'tor here !

function<int(int,int)> f0 = tmp;

std::cout << f0.target<plus>()->internal_state; // should be 7 the same

I would say It seems that expression

function<int(int,int)> f0 = functional_cast<plus(int,int)>(add_floats);

is very similar to

plus tmp( *add_floats.target<plus>() );

function<int(int,int)> f0 = tmp;

Is this correct ?

Thanks
Marco


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