Template specialisation for range of types

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 12 14:04:26 PDT 2017


Meta wrote:

> On Sunday, 12 March 2017 at 20:22:33 UTC, ketmar wrote:
>> Meta wrote:
>>
>>> The reason this doesn't work is when you use ConstOf!U, it's not 
>>> looking for a `const U`, it's looking for the type `ConstOf!U`. I'm not 
>>> sure if this is a bug or not...
>>
>> no, not a bug. this is the way type deconstruction works: it checks if 
>> your type was constructed with a given template.
>
> Yeah, it seems to be checking the pattern rather than the type. However, 
> ConstOf!T is just an alias for const(T), but the alias does not seem to 
> be "unwrapped", even though they are supposed to be transparent.

yeah. "eponymous template" trick.


More information about the Digitalmars-d-learn mailing list