digitalmars.D.learn - Check for ctfe
- "cal" <callumenator gmail.com> Aug 24 2012
- Timon Gehr <timon.gehr gmx.ch> Aug 24 2012
- Timon Gehr <timon.gehr gmx.ch> Aug 25 2012
- "bearophile" <bearophileHUGS lycos.com> Aug 24 2012
- Timon Gehr <timon.gehr gmx.ch> Aug 24 2012
- "cal" <callumenator gmail.com> Aug 24 2012
- Philippe Sigaud <philippe.sigaud gmail.com> Aug 25 2012
- "Minas Mina" <minas_mina1990 hotmail.co.uk> Aug 25 2012
- Philippe Sigaud <philippe.sigaud gmail.com> Aug 25 2012
I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something)
Aug 24 2012
On 08/25/2012 02:06 AM, cal wrote:I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something)
if(__ctfe)
Aug 24 2012
On 08/25/2012 12:53 PM, Minas Mina wrote:Why is it "if( __ctfe )" and not static if.. ?
Both branches need to be compiled in order to have both a ctfe and a runtime version.
Aug 25 2012
cal:I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something)
It's named __ctfe, but unfortunately it's an (immutable) run-time value. When you use it you rely on the dead code elimination optimization done by the compiler. Bye, bearophile
Aug 24 2012
On 08/25/2012 02:15 AM, bearophile wrote:cal:I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something)
It's named __ctfe, but unfortunately it's an (immutable) run-time value. When you use it you rely on the dead code elimination optimization done by the compiler. Bye, bearophile
Which is basically guaranteed to be performed.
Aug 24 2012
On Saturday, 25 August 2012 at 00:13:44 UTC, Timon Gehr wrote:On 08/25/2012 02:06 AM, cal wrote:I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something)
if(__ctfe)
Oh i was using it with static if which didn't work, thanks!
Aug 24 2012
On Sat, Aug 25, 2012 at 2:20 AM, cal <callumenator gmail.com> wrote:On Saturday, 25 August 2012 at 00:13:44 UTC, Timon Gehr wrote:On 08/25/2012 02:06 AM, cal wrote:I saw something on the forum not too long ago about statically checking to see if the current function is being executed at compile time, but can't seem to find it now. Can it be done? (Like static if (__ctfe__) or something)
if(__ctfe)
Oh i was using it with static if which didn't work, thanks!
Same here. I use it rarely, and every time, I first type 'static if (__ctfe) {...'
Aug 25 2012
Why is it "if( __ctfe )" and not static if.. ?
Aug 25 2012
On Sat, Aug 25, 2012 at 12:53 PM, Minas Mina <minas_mina1990 hotmail.co.uk> wrote:Why is it "if( __ctfe )" and not static if.. ?
I guess because __ctfe *must* be a runtime value: its value changes at runtime. And, as 'static if' cannot act on a runtime value...
Aug 25 2012









Timon Gehr <timon.gehr gmx.ch> 