This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFA] Algorithms vs operator* and operator==
- From: Chris Jefferson <caj at cs dot york dot ac dot uk>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Sat, 29 Jan 2005 13:57:39 +0000
- Subject: Re: [RFA] Algorithms vs operator* and operator==
- References: <418A2C03.8040500@suse.de> <4190098F.5000201@cs.york.ac.uk> <41FA57C5.8050200@suse.de>
Paolo Carlini wrote:
chris wrote:
This seems to be the line we have trouble with, as it could lead to
an expensive copy. I haven't fully tested it yet, but I wonder if
this line would be better expressed as:
typeof(*__first) __value = *__first; (where I've only just found
typeof).
I've done some benchmarks, and I'm reasonably convinced that this is
both safe and the most efficent way of doing things. If *__first is a
reference, we just store the reference and access it twice. If
*__first is returned by value, then we only get it by value once and
use it twice. Does this seem safe / sensible?
Hi Chris, today I noticed this thread:
http://gcc.gnu.org/ml/gcc/2005-01/msg01640.html
Not nice...
No, which is a shame, as knowing if something is being passed by
reference or value could be very useful...
Chris