| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
September 16, 2014 Why if(__ctfe)? | ||||
|---|---|---|---|---|
| ||||
Why not "static if(__ctfe)" ? | ||||
September 16, 2014 Re: Why if(__ctfe)? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ilya Yaroshenko | On Tuesday, 16 September 2014 at 13:11:50 UTC, Ilya Yaroshenko wrote:
> Why not "static if(__ctfe)" ?
ctfe is a runtime condition. The function has the same code when run at compile time, it is just being run in a different environment.
| |||
September 16, 2014 Re: Why if(__ctfe)? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Tuesday, 16 September 2014 at 13:17:28 UTC, Adam D. Ruppe wrote:
> On Tuesday, 16 September 2014 at 13:11:50 UTC, Ilya Yaroshenko wrote:
>> Why not "static if(__ctfe)" ?
>
> ctfe is a runtime condition. The function has the same code when run at compile time, it is just being run in a different environment.
Note that if(__ctfe) does not incur a runtime performance penalty. Even in debug builds will the branch be removed.
| |||
September 16, 2014 Re: Why if(__ctfe)? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Rene Zwanenburg | On Tuesday, 16 September 2014 at 13:28:17 UTC, Rene Zwanenburg wrote:
> On Tuesday, 16 September 2014 at 13:17:28 UTC, Adam D. Ruppe wrote:
>> On Tuesday, 16 September 2014 at 13:11:50 UTC, Ilya Yaroshenko wrote:
>>> Why not "static if(__ctfe)" ?
>>
>> ctfe is a runtime condition. The function has the same code when run at compile time, it is just being run in a different environment.
>
> Note that if(__ctfe) does not incur a runtime performance penalty. Even in debug builds will the branch be removed.
It is a kind of magic ;)
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply