This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Paolo Carlini wrote:If we could tell if operator* is returning by value or by reference, would this problem go away? If it is returning by reference, then we simply take that reference and store it. If it returns by value, then if we want to take that value more than once, we may as well copy it into a variable, as surely a dereference and an assignment (possibly with return value optimisation) would be cheaper than 2 dereferences (which both return by value)?
Can you spot anything wrong with this kind of change? If we agree that it's good, there are quite a few places to tweak, both in stl_algo and in stl_algobase (besides locale_facets ;)
*But*, now I remember std::fill and std::fill_n: in order to avoid expensive
copies when _ValueType is "big", we should probably use temporary vars
(like __value) *only* when __is_scalar<_ValueType>::_M_type is true...
Paolo.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |