static if (__ctfe)

Yuriy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 7 03:07:46 PDT 2014


On Wednesday, 7 May 2014 at 09:51:01 UTC, John Colvin wrote:
> On Wednesday, 7 May 2014 at 09:47:20 UTC, Yuriy wrote:
>> Hello, is there any way to static if(__ctfe)? I want to 
>> declare class members which are only available in ctfe. Thanx.
>
> Sadly not as far as I know. What's the use-case? There may be a 
> nice solution none-the-less.

Well, i'm currently playing with std.variant so it can be 
ctfe-friendly. And it works pretty much, however i need to use 
T.stringof.ptr/length instead of typeid (typeid is ctfeable), and 
i'm not sure if it's good for performance in runtime. So for type 
comparison i'd like to compare TypeInfos in rt, and T.stringof in 
ct. Using both with rt if will likely generate more code.


More information about the Digitalmars-d-learn mailing list