== Auszug aus Steven Schveighoffer (schvei...@yahoo.com)'s Artikel > On Wed, 09 Feb 2011 14:59:33 -0500, useo <u...@start.bg> wrote: > > == Auszug aus Steven Schveighoffer (schvei...@yahoo.com)'s Artikel > >> On Wed, 09 Feb 2011 14:35:42 -0500, useo <u...@start.bg> wrote: > >> > Is it possible to create a template which only accepts functions > > or > >> > delegates like this example: > >> > > >> > class Example(T : void function()) { // or ..(T : void delegate > > ()).. > >> > > >> > T callback; > >> > > >> > } > >> > > >> > Where T is a function or a delegate... > >> > > >> > Thanks for every suggestion! > >> class Example(T) if (is(T == delegate) || is(T == function)) > >> { > >> T callback; > >> } > >> -Steve > > > > Is there any chance to do the same for methods like: > > > > void example(T)() { > > } > > > > ... something like: > > > > void bindEvent(T)(if (is(T == delegate) || is(T == function))) ()... > Yes, but you have the order mixed up. > void bindEvent(T)() if (is...) > In general form, a template constraint goes after the declaration, but > before the body of the template. > -Steve
Ah, okay... I already tried the if-statement after the declaration but I always got an error like this: "... semicolon expected following function declaration" I just removed ( and ) from the if-statement and it's working, thanks in again!