Idea for more delegations in <algorithm>
Gabriel Dos Reis
gdr@integrable-solutions.net
Wed Mar 23 17:32:00 GMT 2005
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
More information about the Libstdc++
mailing list