Boost logo

Boost :

Subject: Re: [boost] [Phoenix-3] Is Actor assignable?
From: Joel de Guzman (joel_at_[hidden])
Date: 2011-01-22 09:51:03

On 1/22/2011 10:13 PM, Thomas Heller wrote:
> Joel de Guzman wrote:
>> On 1/22/2011 9:02 PM, Joel de Guzman wrote:
>>> On 1/22/2011 8:17 PM, Thomas Heller wrote:
>>>> Joel de Guzman wrote:
>>>>> On 1/21/2011 8:39 PM, Michel MORIN wrote:
>>>>>> I have another question about Phoenix 3.
>>>>>> Is the copy assignment of Actors no-op, or does it really copy the
>>>>>> contents?
>>>>>> Actor a;
>>>>>> Actor b = ...;
>>>>>> a = b; // no-op?
>>>>> It should copy the contents. Thomas?
>>>> Not really. It needs to create the assign actor (that means the
>>>> expression template representing the assignment operation.
>>>> It is neither a no-op nor is the assignment "executed". Remember the
>>>> stuff about phoenix being lazy ;)?
>>> No! That's not the case here. There *is* still the immediate assignment
>>> operator being called when two actors are of the same type (e.g.
>>> when lhs and rhs are phoenix values). In these cases, a *is*
>>> assigned to *b*. Thus, for values, the contents are copied.
>>> Ditto for copy construction of course.
>> Oops, I meant b is assigned to a of course :-P
> Seems like i don't stand a chance. I was trying to find a use case where you
> might want the lazy version of the assignment ... couldn't find one.
> Added the operator=(actor const&) to phoenix 3.
> Thanks for the hint.

But here's where it gets tricky: Even a slight change in type
will make it lazy. Consider a: value<int> b: value<short>.


Joel de Guzman

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