write a function template specialisation that tests if an argument is known at compile time

Paul Backus snarwin at gmail.com
Sun Aug 12 04:26:30 UTC 2018


On Sunday, 12 August 2018 at 02:17:21 UTC, Cecil Ward wrote:
> I was thinking about reflection and powerful things like 
> traits. Would a test to see if a static if compile do the trick 
> ? You ask the question using traits : "does the following 
> compile? : { static if ( mask == 3 ) { }; }"  - any use?

When the function is being compiled, it has no idea where its 
arguments will be coming from. So your `__traits(compiles, ...)` 
test will always evaluate to false.


More information about the Digitalmars-d-learn mailing list