Check if tuple contains value at compile time

bearophile bearophileHUGS at lycos.com
Sun May 5 04:17:09 PDT 2013


Diggory:

> Is the behaviour of the empty [] when applied to tuples 
> documented anywhere?

I don't remember.


> The problem is that this doesn't work if the tuple is empty:
> Error: template std.algorithm.canFind does not match any 
> function template declaration.
>
> And unfortunately in the situation I need it for an empty tuple 
> is one of the most likely scenarios.

I see. Then a good idea is to create a little function, to solve 
this. It should contain a static if that tests for the empty 
tuple and returns false in that case, and otherwise uses the 
canFind.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list