Re: std.traits : Select - could it be better?

2018-07-06 Thread Steven Schveighoffer via Digitalmars-d
On 7/5/18 10:17 PM, SrMordred wrote: I find another solution :) template Try(alias T, Args...) {     static if( is( T!Args ) )     alias Try = T!Args; } alias U = Select!( isPointer!T, Try!( PointerTarget, T ), T ); I like it! -Steve

Re: std.traits : Select - could it be better?

2018-07-05 Thread SrMordred via Digitalmars-d
On Thursday, 5 July 2018 at 20:29:02 UTC, Steven Schveighoffer wrote: On 7/5/18 4:27 PM, Steven Schveighoffer wrote: template BetterSelect(bool cond, alias temp1, alias temp2, Args...) {    import std.meta : Instantiate;    static if(cond)   alias BetterSelect = Instantiate!(temp1, Args)

Re: std.traits : Select - could it be better?

2018-07-05 Thread Steven Schveighoffer via Digitalmars-d
On 7/5/18 4:27 PM, Steven Schveighoffer wrote: template BetterSelect(bool cond, alias temp1, alias temp2, Args...) {    import std.meta : Instantiate;    static if(cond)   alias BetterSelect = Instantiate!(temp1, Args);    else   alias BetterSelect = Instantiate!(temp2, Args); } ug

Re: std.traits : Select - could it be better?

2018-07-05 Thread Steven Schveighoffer via Digitalmars-d
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

Re: std.traits : Select - could it be better?

2018-07-05 Thread Andrei Alexandrescu via Digitalmars-d
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

std.traits : Select - could it be better?

2018-07-05 Thread SrMordred via Digitalmars-d
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 lo