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]

Re: [RFA] Algorithms vs operator* and operator==


Paolo Carlini wrote:

Paolo Carlini wrote:

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...


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)?

Although at the moment I don't believe it's possible to get the return value of a function ¬_¬ , would it be stunningly hard to add as a g++ extension (and a useful one at that, people always seem to be asking for result_of)?

Chris

Paolo.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]