__traits(isSame, TemplateOf ...) errors and some Idiomatic D questions

aliak something at something.com
Tue Jan 9 00:11:09 UTC 2018


On Monday, 8 January 2018 at 23:03:46 UTC, H. S. Teoh wrote:
> On Mon, Jan 08, 2018 at 10:59:44PM +0000, aliak via 
> Digitalmars-d-learn wrote: [...]
>> onlineapp.d(61): Error: template std.traits.TemplateOf does 
>> not match any template declaration. And I use it like this:
>> 
>> enum r1Sorted = __traits(isSame, TemplateOf!(R1), SortedRange);
>
> This seems unnecessarily complicated.  What about this instead?
>
> 	enum r1Sorted = is(R1 : SortedRange!T, T...);
>
> Basically, what that is-expression means is: "Is R1 a template 
> of the form `SortedRange!T` where T is some list of template 
> arguments".
>
> Generally, using __traits directly is usually not recommended 
> unless there's no other way to achieve what you want.
>
>
> T

Wow nice! Super nice :D Thanks! And ah I see, I suppose the 
double underscore kinda hints at that as well?


More information about the Digitalmars-d-learn mailing list