What is the best way to program over "abstract" types in D?
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sat Nov 23 20:22:44 UTC 2019
On Saturday, 23 November 2019 at 15:09:44 UTC, Adam D. Ruppe
wrote:
> On Saturday, 23 November 2019 at 13:17:49 UTC, mipri wrote:
>> template isNamed(alias T) {
>> enum isNamed = hasStaticMember!(T, "secretlyIsNamed");
>> }
>
> this looks like a place to use a @Named uda!
>
> @Named struct World {}
> @Named struct Bob {}
>
> or mebbe
>
> @implements!Named
>
> is an option to explore too. Then it cleans up the
> secretlyIsNamed reflection issue.
I have little to no experience with UDA in D. So I would mark a
struct as @SetLike or @ArrayLike, but how would I typecheck that
it has the required methods and aliased types?
I guess it is possible to use introspection somehow?
More information about the Digitalmars-d-learn
mailing list