Re: isCallableCTFE trait to test whether an expression is callable during CTFE

2013-07-10 Thread timotheecour
On Thursday, 11 July 2013 at 03:29:13 UTC, Kenji Hara wrote: On Thursday, 11 July 2013 at 03:10:38 UTC, timotheecour wrote: On Thursday, 11 July 2013 at 02:17:13 UTC, Timothee Cour wrote: [snip] can we add this to std.traits? it allows (among other things) to write unittests for CTFE, etc.

Re: isCallableCTFE trait to test whether an expression is callable during CTFE

2013-07-10 Thread Kenji Hara
On Thursday, 11 July 2013 at 03:10:38 UTC, timotheecour wrote: On Thursday, 11 July 2013 at 02:17:13 UTC, Timothee Cour wrote: [snip] can we add this to std.traits? it allows (among other things) to write unittests for CTFE, etc. Phobos has an internal helper function for testing CTFEable. h

Re: isCallableCTFE trait to test whether an expression is callable during CTFE

2013-07-10 Thread timotheecour
On Thursday, 11 July 2013 at 02:17:13 UTC, Timothee Cour wrote: template isCallableCTFE(alias fun){ template isCallableCTFE_aux(alias T){ enum isCallableCTFE_aux=T; } enum isCallableCTFE=__traits(compiles,isCallableCTFE_aux!(fun())); } template isCallableCTFE2(fun...){ enum isCallableCTFE2=tru

Re: isCallableCTFE trait to test whether an expression is callable during CTFE

2013-07-10 Thread Timothee Cour
On Wed, Jul 10, 2013 at 7:16 PM, Timothee Cour wrote: > template isCallableCTFE(alias fun){ > template isCallableCTFE_aux(alias T){ > enum isCallableCTFE_aux=T; > } > enum isCallableCTFE=__traits(compiles,isCallableCTFE_aux!(fun())); > } > > template isCallableCTFE2(fun...){ > enum isCallableCTFE

isCallableCTFE trait to test whether an expression is callable during CTFE

2013-07-10 Thread Timothee Cour
template isCallableCTFE(alias fun){ template isCallableCTFE_aux(alias T){ enum isCallableCTFE_aux=T; } enum isCallableCTFE=__traits(compiles,isCallableCTFE_aux!(fun())); } template isCallableCTFE2(fun...){ enum isCallableCTFE2=true; } unittest{ int fun1(){ return 1; } auto fun1_N(){ import std.a