Aliases and UDA's

Manu via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 30 14:03:30 PST 2014


On 30 December 2014 at 22:51, Daniel Murphy via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> "Manu via Digitalmars-d"  wrote in message
> news:mailman.3785.1419919315.9932.digitalmars-d at puremagic.com...
>
>> I guess the reason is that A is not really a thing; it is translated
>> to S!int when being given to T?
>> Is that the point where "world" is lost?
>
>
> Yes.  "world" is still there, but you can't actually get the symbol A.
>
>> I'm not really sure how I can achieve what I want here... I need to
>> attribute particular instantiations of a template struct as shown.
>
>
> Why does it have to be UDAs?  You can easily put the 'attributes' inside S
> or define a template for getting the attributes from an arbitrary S.
>
> Something like:
> enum myAttributes(T : S!int) = TypeTuple!("world");
> enum myAttributes(T : S!U, U) = TypeTuple!();

In this particular case, I'm actually attributing pixel structures
with an enum that describes the pixel format to a 3rd party library.
I can approach it differently, but it was just a particularly
convenient and un-intrusive way to get the data through to the 3rd
party API.
It seemed nicer as an attribute; if I pollute the type with the 3rd
party enum by making it a template arg or something, then my type
can't exist on its own without knowledge of the particular 3rd party
lib. Like, it would expect to be given this enum to instantiate, and
that's unnecessary restrictive.

I guess I'll have to explore some alternatives.


More information about the Digitalmars-d mailing list