www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - In need for CommonOriginalType

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
In order to make

https://github.com/nordlow/justd/blob/master/enums.d

more type-safe (restrict type arguments to EnumUnion) I need a 
type trait, say,

CommonOriginalType(E...)

Do I have to use recursion (like in CommonType) to implement this 
or is there a better way?

See also:
http://forum.dlang.org/thread/bjburcdtcejohtpmqmay forum.dlang.org?page=2#post-lveiwblfoommtjninxki:40forum.dlang.org
May 02 2014
next sibling parent reply Joseph Rushton Wakeling via Digitalmars-d-learn writes:
On 02/05/14 19:24, "Nordlöw" via Digitalmars-d-learn wrote:
 Do I have to use recursion (like in CommonType) to implement this or is there a
 better way?
Won't it work to use, is(CommonType!(OriginalType!T1, OriginalType!T2) ... ?
May 02 2014
parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
   is(CommonType!(OriginalType!T1, OriginalType!T2)

 ... ?
I need it to be variadic. I cracked it: import std.typetuple: staticMap; import std.traits: CommonType, OriginalType; alias CommonOriginalType(T...) = CommonType!(staticMap!(OriginalType, T)); /per
May 02 2014
prev sibling parent Joseph Rushton Wakeling via Digitalmars-d-learn writes:
On 02/05/14 20:03, Joseph Rushton Wakeling via Digitalmars-d-learn wrote:
 On 02/05/14 19:24, "Nordlöw" via Digitalmars-d-learn wrote:
 Do I have to use recursion (like in CommonType) to implement this or is there a
 better way?
Won't it work to use, is(CommonType!(OriginalType!T1, OriginalType!T2)
... missing a closing bracket there :-P
May 02 2014