DMD 0.177 release
Sean Kelly
sean at f4.ca
Fri Dec 15 01:02:15 PST 2006
Lionello Lunesu wrote:
> Andrei Alexandrescu (See Website for Email) wrote:
>> Lionello Lunesu wrote:
>>> Walter Bright wrote:
>>>> It is possible to force the return type of opAssign. But I'd suggest
>>>> making it an S*, with the rewrite to:
>>>>
>>>> *(a.opAssign(b))
>>>>
>>>
>>> class C {
>>> C* opAssign(...) {...}
>>> }
>>> struct S {
>>> S* opAssign(...) {...}
>>> }
>>>
>>> Seriously?? Ugh.
>>>
>>> Why not just "C opAssign" and "S opAssign"? In the opCall discussion
>>> you said yourself that the return value will be optimized.
>>>
>>> Am I missing something?
>>
>> There is no *extra* copying, in the sense that exactly one copy is
>> done. But most of the time the copy obtained is not used, in which
>> case that one copy is spurious.
>
> I'd think that the optimizer would not only eliminate the extra copy,
> but the entire construction of the return value .. No?
If the routine is inlined perhaps, but otherwise not.
Sean
More information about the Digitalmars-d-announce
mailing list