Re: is expression and type tuples

2015-03-04 Thread bearophile via Digitalmars-d-learn
Jack Applegame: On Tuesday, 3 March 2015 at 17:49:24 UTC, bearophile wrote: That's 1 + n-1 :-) Could you please explain what does '1 + n-1' mean? This is your code: template Is(ARGS...) if(ARGS.length % 2 == 0) { enum N = ARGS.length/2; static if(N == 1) enum Is = is(ARGS[0] :

is expression and type tuples

2015-03-03 Thread Jack Applegame via Digitalmars-d-learn
Seems like is expression doesn't support type tuples: pragma(msg, is(short : int)); // true enum Test(ARGS...) = is(ARGS[0..2] : ARGS[2..4]); pragma(msg, is(Test!(int, int, int, int))); // false pragma(msg, Test!(int, short, int, int)); // false Is it by design, or just

Re: is expression and type tuples

2015-03-03 Thread bearophile via Digitalmars-d-learn
Jack Applegame: Seems like is expression doesn't support type tuples: pragma(msg, is(short : int)); // true enum Test(ARGS...) = is(ARGS[0..2] : ARGS[2..4]); pragma(msg, is(Test!(int, int, int, int))); // false pragma(msg, Test!(int, short, int, int)); // false

Re: is expression and type tuples

2015-03-03 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 3 March 2015 at 16:42:22 UTC, bearophile wrote: But it should be not too much hard to implement it your code. Just use two is(), or use recursion (with splitting in two, and not 1 + n-1). Bye, bearophile I already have one: template Is(ARGS...) if(ARGS.length % 2 == 0) {

Re: is expression and type tuples

2015-03-03 Thread bearophile via Digitalmars-d-learn
Jack Applegame: or use recursion (with splitting in two, and not 1 + n-1). Bye, bearophile I already have one: template Is(ARGS...) if(ARGS.length % 2 == 0) { enum N = ARGS.length/2; static if(N == 1) enum Is = is(ARGS[0] : ARGS[1]); else enum Is = is(ARGS[0] : ARGS[N])

Re: is expression and type tuples

2015-03-03 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 3 March 2015 at 17:49:24 UTC, bearophile wrote: That's 1 + n-1 :-) Could you please explain what does '1 + n-1' mean?

Re: Comparing mixed expression and type tuples. How?

2010-05-26 Thread Simen kjaeraas
bearophile bearophileh...@lycos.com 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).

Re: Comparing mixed expression and type tuples. How?

2010-05-26 Thread Simen kjaeraas
Simen kjaeraas simen.kja...@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

Re: Comparing mixed expression and type tuples. How?

2010-05-26 Thread bearophile
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

Re: Comparing mixed expression and type tuples. How?

2010-05-26 Thread Simen kjaeraas
bearophile bearophileh...@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