UDA inheritance

drug drug2004 at bk.ru
Thu Sep 10 13:14:47 UTC 2020

On 9/10/20 4:06 PM, Joseph Rushton Wakeling wrote:
> Hello folks,
> Is there any way to define UDAs such that they automatically inherit 
> other UDA definitions?
> For example, suppose I define:
>      enum BaseUDA { A, B }
> Is there a way to define `AnotherUDA` such that if `hasUDA!(T, 
> AnotherUDA)` then it is a given that `hasUDA!(T, BaseUDA)` will also be 
> true?  (And similarly for the `A`, `B` specializations?)
> The use-case here is to create a UDA that defines some general 
> distinction of code properties, and to allow downstream code to define 
> its own more specialized cases of that distinction.
> Thanks in advance for any thoughts or advice!
> Thanks and best wishes,
>        -- Joe

Just a thought - couldn't you use classes for this? Get an UDA and check 
if it is a descendant of the specific class.

More information about the Digitalmars-d-learn mailing list