Re: Check if tuple contains value at compile time

2013-05-05 Thread bearophile
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

Re: Check if tuple contains value at compile time

2013-05-04 Thread Simen Kjaeraas
On 2013-05-05, 01:42, Diggory wrote: I'm trying to test using a static if statement if a tuple of strings contains a particular string. What's the easiest/best way to do this? http://dlang.org/phobos/std_typetuple#.staticIndexOf -- Simen

Re: Check if tuple contains value at compile time

2013-05-04 Thread Diggory
On Sunday, 5 May 2013 at 00:10:27 UTC, Simen Kjaeraas wrote: On 2013-05-05, 01:42, Diggory wrote: I'm trying to test using a static if statement if a tuple of strings contains a particular string. What's the easiest/best way to do this? http://dlang.org/phobos/std_typetuple#.staticIndexOf

Re: Check if tuple contains value at compile time

2013-05-04 Thread bearophile
Diggory: It's not a TypeTuple, it's a tuple of strings. Then one simple way to do it is to convert it into an array of strings, and then use canFind: [mytuple[]].canFind(needle) Bye, bearophile

Re: Check if tuple contains value at compile time

2013-05-04 Thread Diggory
On Sunday, 5 May 2013 at 00:33:34 UTC, bearophile wrote: Diggory: It's not a TypeTuple, it's a tuple of strings. Then one simple way to do it is to convert it into an array of strings, and then use canFind: [mytuple[]].canFind(needle) Bye, bearophile OK, that makes sense but I'm not

Re: Check if tuple contains value at compile time

2013-05-04 Thread Diggory
On Sunday, 5 May 2013 at 01:44:19 UTC, bearophile wrote: Diggory: The documentation seems too say that [mytuple] will make an array, Nope. You have to extract the inherent typetuple first. And this is what the [] syntax does (tested): import std.stdio, std.typecons, std.algorithm; void