digitalmars.D.learn - Comparing mixed expression and type tuples. How?
- Simen kjaeraas (6/6) May 25 2010 import std.typetuple;
- bearophile (4/5) May 25 2010 Look for this problem in the digitalmars.D.learn group, because I have s...
- Simen kjaeraas (21/26) May 26 2010 Yeah. is( T == U ) only works for type tuples, though. Had to write my
- Simen kjaeraas (5/6) May 26 2010 Now if only someone would fix
- bearophile (4/5) May 26 2010 Looks nice. There are many small bits of functionality like that that ar...
- Simen kjaeraas (4/8) May 26 2010 Done: http://d.puremagic.com/issues/show_bug.cgi?id=4239
import std.typetuple; static assert( is( TypeTuple!( int, "a" ) == TypeTuple!( int, "a" ) ); The above code asserts. Is there some other way to compare mixed tuples, or should i roll my own comparison function? -- Simen
May 25 2010
Simen kjaeraas Wrote:static assert( is( TypeTuple!( int, "a" ) == TypeTuple!( int, "a" ) );Look for this problem in the digitalmars.D.learn group, because I have seen this problem recently solved here (I don't remember the solution, it was easy). Bye, bearophile
May 25 2010
bearophile <bearophileHUGS lycos.com> wrote:Simen kjaeraas Wrote:Yeah. is( T == U ) only works for type tuples, though. Had to write my own comparison code. I'd recommend something like this be added to Phobos. template SameTuple( T... ) { template As( U... ) { static if ( T.length != U.length ) { enum As = false; } else static if ( T.length == 0 ) { enum As = true; } else static if ( T.length == 1 ) { enum As = is( T[0] == U[0] ) || T[0] == U[0]; } else { enum As = SameTuple!( T[1..$] ).As!( U[1..$] ) && is( T[0] == U[0] ) || T[0] == U[0]; } } } Usage: if ( SameTuple!( int, "a" ).As( int, "a" ) ) {} -- Simenstatic assert( is( TypeTuple!( int, "a" ) == TypeTuple!( int, "a" ) );Look for this problem in the digitalmars.D.learn group, because I have seen this problem recently solved here (I don't remember the solution, it was easy).
May 26 2010
Simen kjaeraas <simen.kjaras gmail.com> wrote:if ( SameTuple!( int, "a" ).As( int, "a" ) ) {}Now if only someone would fix http://d.puremagic.com/issues/show_bug.cgi?id=242 -- Simen
May 26 2010
Simen kjaeraas:I'd recommend something like this be added to Phobos.<Looks nice. There are many small bits of functionality like that that are missing still in Phobos and can be added. I suggest you to put that code in a bugzilla entry (otherwise I can do it myself) with a good unittest{} and if you want a ddoc comment too. Bye, bearophile
May 26 2010
bearophile <bearophileHUGS lycos.com> wrote:Looks nice. There are many small bits of functionality like that that are missing still in Phobos and can be added. I suggest you to put that code in a bugzilla entry (otherwise I can do it myself) with a good unittest{} and if you want a ddoc comment too.Done: http://d.puremagic.com/issues/show_bug.cgi?id=4239 -- Simen
May 26 2010