August 14, 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.
August 14, 2018
On Tuesday, 14 August 2018 at 03:01:11 UTC, Cecil Ward wrote:
> 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.

If you are that far, then it seems simple. You always call it as a template:
T myfunc(uint mask, T)(T x) {}

In myfunc you decide if umask is compile time or not. If not, then call a templated function with static if's for specific values, otherwise call the regular function.

1 2
Next ›   Last »