Jeremie Pelletier:

> http://bartoszmilewski.wordpress.com/2009/10/21/what-does-haskell-have-to-do-with-c/
> Bartosz's second part of 'Template Metaprogramming Made Easy (Huh?)', 
> its quite a read :)

I don't like the name "allSatisfy", I use the "All" named, that's similar to 
the templated function "all". And I don't remember if Phobos also defined an 
"Any" too (that uses || inside instead of &&). I use also a "Map" template, 
that's useful for example to cast all items of a tuple to a different type. I 
have defined "Filter" template too, but that's less useful.

Regarding the variant shown in that blog post:

template allSatisfy(alias F, T...) {
    static if (T.length == 1) {
        alias F!(T[0]) allSatisfy;
    } else {
        private enum bool tailResult = allSatisfy!(F, T[1..$]);
        enum bool allSatisfy = F!(T[0]) && tailResult;
    }
}

Why can't that be used in the same way as the template that inside defines the 
"allSatisfy" name only? Even if it contains another name, the "tailResult", the 
"allSatisfy" alias is there still... (In those situations as workaround I use a 
second allSatisfy_helper template, and the allSatisfy template just uses 
allSatisfy_helper.result. But it's not handy).

Bye,
bearophile

Reply via email to