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

Cecil Ward d at cecilward.com
Tue Aug 14 03:01:11 UTC 2018


On Tuesday, 14 August 2018 at 02:53:01 UTC, Cecil Ward wrote:
> On Sunday, 12 August 2018 at 12:27:59 UTC, Alex wrote:
>> On Saturday, 11 August 2018 at 05:17:51 UTC, Cecil Ward wrote:
>>> T myfunc(T)( T x, uint mask )
>>>    if ( mask == 3 )
>>>    {
>>>    return fast_func( x, mask );
>>>    }
>>>
>>> [...]
>>
>> Is it the volcano pattern you are looking for?
>> https://p0nce.github.io/d-idioms/#Is-this-available-at-compile-time-or-runtime?
>
> Wow, now that _is_ clever. I think that is definitely a big 
> part of it.
>
> Now somehow after having used a static if to select the 
> known-at-compile-time case I then have to test the argument for 
> particular values.
>
> So how to get the next step along the way?

Would it be ok to ask Walter maybe ? I am so far out of my depth 
here tho.


More information about the Digitalmars-d-learn mailing list