Optional tags and attributes
Timon Gehr
timon.gehr at gmx.ch
Sat Jan 18 12:17:07 PST 2014
On 01/18/2014 03:50 AM, Stanislav Blinov wrote:
>>
>
> Oh, I see now where it went the wrong way. From my own example, of
> course :)
>
> Surely I was meaning:
>
> class Careful(T) {
> //...
> void thisIsSoPolymorphic() nothrow(isNoThrow!(T.foo)) { ... }
> //...
> }
>
> Something to that extent. So that yes, the function itself is not a
> template.
Well, but it will be annotated nothrow anyway if possible. Inference is
not actually limited in the implied way.
In case you _really_ want to be explicit about this (and you seem not
to), the general problem precluding a nice library implementation is
that built-in attributes cannot be aliased.
You can always use a string mixin though:
mixin(`void thisIsSoPolymorphic()`~(isNoThrow!(T.foo)?:"nothrow":"")~q{{
...
}});
This easily scales to all attributes you may find interesting:
mixin(`void thisIsSoPolymorphic()`~stringOfAttributes!(T.foo)~q{{
...
}});
More information about the Digitalmars-d
mailing list