Re: The is expression

2011-04-10 Thread David Nadlinger
On 4/5/11 12:21 PM, enuhtac wrote: […] static if (is(int[10] W : W[V], int V)) what is the essential difference to: static if( is( A!(int, "xxx") T == A!(T, s), string s ) ) This is probably merely a bug, I just stumbled across something similar: http://d.puremagic.com/issues/show_bu

Re: The is expression

2011-04-05 Thread Philippe Sigaud
compiler knows about arrays and associated arrays, whereas it isn't smart enough to extract the correct information from a templated type? The is() expression was not developed from first principles: it grew 'organically' as a hodge-podge of tricks and needs.

Re: The is expression

2011-04-05 Thread enuhtac
Am 03.04.2011 16:11, schrieb Philippe Sigaud: > On Sat, Apr 2, 2011 at 13:05, enuhtac wrote: >> This is the type I would like to check for: >> >> struct A( T, string s ) >> { ... }; > Hi, > > the trick is to use a function do the work for you. Let's define isAnA: > > void isAnA(T, string s)( A!(T,

Re: The is expression

2011-04-03 Thread Philippe Sigaud
On Sat, Apr 2, 2011 at 13:05, enuhtac wrote: > This is the type I would like to check for: > > struct A( T, string s ) > { ... }; Hi, the trick is to use a function do the work for you. Let's define isAnA: void isAnA(T, string s)( A!(T,s) a) { } isAnA can only be called (compiled) with your A.

Re: The is expression

2011-04-02 Thread enuhtac
Am 02.04.2011 04:00, schrieb Caligo: > On Fri, Apr 1, 2011 at 5:14 PM, enuhtac wrote: >> Hello, >> >> the "is" expression is a great feature of D - but its use is not very >> intuitive, at least for me. >> I'm trying to write a template that figure

Re: The is expression

2011-04-02 Thread enuhtac
; > What does ", string s" do here inside the is expression? > > Denis A takes two template parameters: a type "T" and a value "string s". So I need to specify both parameters in the is expression. In the D manual you find something similar: static if (is(int[10] W : W[V], int V))

Re: The is expression

2011-04-02 Thread spir
On 04/02/2011 12:14 AM, enuhtac wrote: template isA( T ) { static if( is( T U == A!( U, s ), string s ) ) enum bool isA = true; else enum bool isA = false; }; What does ", string s" do here inside the is expression? Denis -- _ vita

Re: The is expression

2011-04-01 Thread Caligo
On Fri, Apr 1, 2011 at 5:14 PM, enuhtac wrote: > Hello, > > the "is" expression is a great feature of D - but its use is not very > intuitive, at least for me. > I'm trying to write a template that figures out if the template > parameter is of a given type. &

The is expression

2011-04-01 Thread enuhtac
Hello, the "is" expression is a great feature of D - but its use is not very intuitive, at least for me. I'm trying to write a template that figures out if the template parameter is of a given type. This is the type I would like to check for: struct A( T, string s ) { ... }; One