bearophile <[email protected]> wrote:

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).

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" ) ) {}

--
Simen

Reply via email to