digitalmars.D.learn - Checking for CTFE at compile-time
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (7/7) Nov 07 2018 Opposite to run-time checking via
- H. S. Teoh (10/18) Nov 07 2018 It's actually not a "run-time" check, because the backend optimizer will
Opposite to run-time checking via if (__ctfe) { // } is there no way of checking at compile-time whether the current scope of a function is being executed in CTFE?
Nov 07 2018
On Wed, Nov 07, 2018 at 10:01:15PM +0000, Per Nordlöw via Digitalmars-d-learn wrote:Opposite to run-time checking via if (__ctfe) { // }It's actually not a "run-time" check, because the backend optimizer will optimize out the true branch (check the emitted asm to confirm this).is there no way of checking at compile-time whether the current scope of a function is being executed in CTFE?`if (__ctfe)` *is* a compile-time check. I think you're getting confused by the blanket term "compile-time", that actually means (at least) two different things. See: https://wiki.dlang.org/User:Quickfur/Compile-time_vs._compile-time T -- Real men don't take backups. They put their source on a public FTP-server and let the world mirror it. -- Linus Torvalds
Nov 07 2018