This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Idea for more delegations in <algorithm>
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Chris Jefferson <caj at cs dot york dot ac dot uk>
- Cc: Paolo Carlini <pcarlini at suse dot de>, libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: 23 Mar 2005 18:26:39 +0100
- Subject: Re: Idea for more delegations in <algorithm>
- Organization: Integrable Solutions
- References: <4241980D.7010908@suse.de> <4241A3CC.8040208@cs.york.ac.uk>
Chris Jefferson <caj@cs.york.ac.uk> writes:
| Paolo Carlini wrote:
| | Hi everyone, hi Chris,
| |
| | today I got an idea, or better I *read* an idea: do you know N1758?
| | Basically, Siek et al., explain at pag. 37 how to to do dispatching
| | without tag types. Nothing very exoteric, actually, if you know
| | enable_if, but this strikes me as potentially solving at the root the
| | optimization problems with empty classes! Because we do *not* have
| | additional parameters in the function calls!
| |
| | For instance, they implement "do the right thing" for vector as:
| |
| | template<typename InputIterator>
| | vector<InputIterator first, InputIterator last,
| | typename
| | enable_if<(!is_integral<InputIterator>::value), void*>::type = 0);
| |
| | Or, for some reason, we have troubles with this too? :(
|
| Unless I'm going mad (possible), default parameters are inserted and
| passed by the compiler (at least on x86), so this will in fact be worse,
| because that "0" will always be created and passed by the compiler
| (because it might be needed for all it knows) whereas the empty classes
| might eventually be optimised away with compiler improvements.
You're right.
| My simple attempts to fix this were defeated by the non-existance of
| partial function specialisations, so I tried wrapping the functions in
| structs, and got something much like:
that is the traditional pattern used everywhere in the library.
-- Gaby