bearophile <[email protected]> wrote:
But a bigger problem is that I can't see a way to define a conditionally
pure templated function, for example a map() that is pure if the given
function pointer is pure, and is not pure otherwise:
This is fairly simple currently:
template map( alias fn ) { // blah blah blah, whatever is necessary here
static if ( isPure!fn ) {
pure map( Range )( Range r ) { ... }
} else {
auto map( Range )( Range r ) { ... }
}
}
Of course, this leads to code duplication, which is unwanted. In cases
like this, I long for some features of the C preprocessor, which would
be able to insert any kind of code wherever it wants.
This feature request, and Steve's problems with final (in
std.pattern..mixin temptes..std.concurrency), makes me think there
should be some way to specify all (or at least most) such conditionally.
There seems to be a real need for it.
--
Simen