From: Philippe Mori (philippe_mori_at_[hidden])
Date: 2005-04-25 12:01:58
> I have found a couple of "undocumented features" in operators.hpp:
> 1) The return values from a lot of the binary operators should be declared
> const, so that it is not possible to assign to the temporary object that
> results from the operation. An example:
Well, operators are generally defined in the same form as predefined
operators and thus does not returns const objects.
You might look into the book "C++ Coding Standard" by Herb
Sutter and Andrei Alexandrescu at items 27 and 55 in particular.
If operators returns const objects the many functions should probably
also returns const objects.
As mentionned in the book, returning const objects disable some
usefull construct on temporary objects (like calling a non-const
member function) and might break some existing client code.
So for consistency, I think that boost operators should returns
non-const objects as most librairies do (including probably the
STL for complex numbers).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk