allSatisfy could use some constraints
Andrej Mitrovic
andrej.mitrovich at gmail.com
Thu Sep 22 17:03:58 PDT 2011
On 9/23/11, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> Though given that allSatisfy!(isNumeric, int, short) will work with
> std.traits.isNumeric and not std.string.isNumeric, I suspect that a template
> constraint could be added which would fix the problem simply by checking
> whether the compilation succeeds or not with the given arguments.
I'm not sure if allSatisfy was meant to be used with regular
functions, it's used with templates and types (hence it's in
typetuple). I think an alternative "all" template for runtime
arguments was already proposed.
My problem is not the name clashes but the fact that the error message
is in the body of the allSatisfy template, and this is exactly where
constraints come in handy. It took me a while before I figured out
that std.string had the same function name, but I'm using an alias now
to remedy this.
More information about the Digitalmars-d-learn
mailing list