std.traits : Select - could it be better?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Jul 5 19:35:32 UTC 2018


On 7/5/18 2:50 PM, SrMordred wrote:
> alias U = Select!( isPointer!T, PointerTarget!T, T );
> 
> This don´t compile if T are not a pointer;
> 
> so you have to do this:
> 
> static if( isPointer!T )
>      alias U = PointerTarget!T;
> else
>      alias U = T;
> 
> Shouldnt the 'correct' way of Select to work is ignoring the choice that 
> was not taken?
> 
> I love the idea of Select, but because of this I almost never use it.

mixin("alias U = " ~ Select!(isPointer!T, "PointerTarget!T", "T") ~ ";");

Ehm this is actually not better :o).

Andrei


More information about the Digitalmars-d mailing list