|
Boost : |
From: Gabriel Dos Reis (Gabriel.Dos-Reis_at_[hidden])
Date: 2002-02-22 10:30:37
nbecker_at_[hidden] writes:
| >>>>> "Gabriel" == Gabriel Dos Reis <Gabriel.Dos-Reis_at_[hidden]> writes:
|
| Gabriel> nbecker_at_[hidden] writes:
| Gabriel> | I totally agree that it would be much easier to port legacy code if
| Gabriel> | your could say:
| Gabriel> |
| Gabriel> | real(z) = x;
| Gabriel> |
| Gabriel> | However, I should point out that it is easy to make a proxy class that
| Gabriel> | does just this.
|
| Gabriel> Whether it is easy to make a proxy class for that doesn't suppress the
| Gabriel> problem. In fact, there is no way one could make a modifiable lvalue out
| Gabriel> of real(z), that was my point.
|
| Let me make 2 points:
|
| 1) I completely agree that the design of complex, which disallows
| direct access to real and imag, is a mistake. real() and imag()
| should return a ref. I argued this before, but I got responses to
| the effect that someone may want to represent complex numbers as
| mag, phase, etc. Personally, I find this argument unconvincing.
You're right in finding that argument unconvincing because the
standard unambigously says that complex<> stores the real and
imaginary parts.
But as noted by Dave, having a modifiable lvalue is half of the
story. The other half is layout. C99 makes a little step further: a
_Complex has a layout compatible with that of an array of two scalars,
with the slot-0 <-> real-part and slot-1 <-> imaginary-part.
| 2) I don't understand why you say you can't make a modifiable lvalue.
You cannot say &real(z);
There is no way of saying that, using only proxy classes.
-- Gaby
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk