Adding pure to a function type
jmh530
john.michael.hall at gmail.com
Thu Oct 26 16:14:11 UTC 2017
On Thursday, 26 October 2017 at 16:06:28 UTC, jmh530 wrote:
> On Thursday, 26 October 2017 at 15:47:03 UTC, Andrei
> Alexandrescu wrote:
>>
>> s/less hideous/even more awesome/
>>
>> No need to be testy :o).
>>
>> I noticed there's no way to say "just leave linkage as is". I
>> tried SetFunctionAttributes!(typeof(&impl), null,
>> FunctionAttribute.pure_) and
>> SetFunctionAttributes!(typeof(&impl), "",
>> FunctionAttribute.pure_) but neither worked. Should I file a
>> bug?
>>
>>
>> Andrei
>
> How about:
>
> SetFunctionAttributes!(typeof(&impl), functionLinkage!(&impl),
> FunctionAttribute.pure_)
Or we can just add in additional overloads like:
template SetFunctionAttributes(T, uint attrs)
if (isFunctionPointer!T || isDelegate!T)
{
alias SetFunctionAttributes =
FunctionTypeOf!(SetFunctionAttributes!(T, functionLinkage!T,
attrs));
}
template SetFunctionAttributes(T, uint attrs)
if (is(T == function))
{
alias SetFunctionAttributes =
FunctionTypeOf!(SetFunctionAttributes!(T*, attrs));
}
template SetFunctionAttributes(T, string linkage)
if (isFunctionPointer!T || isDelegate!T)
{
alias SetFunctionAttributes =
FunctionTypeOf!(SetFunctionAttributes!(T, linkage,
functionAttributes!T));
}
template SetFunctionAttributes(T, string linkage)
if (is(T == function))
{
alias SetFunctionAttributes =
FunctionTypeOf!(SetFunctionAttributes!(T*, linkage));
}
More information about the Digitalmars-d
mailing list