Closest Common Type

BCS ao at pathlink.com
Fri May 16 10:34:44 PDT 2008


Reply to Lutger,

> BCS wrote:
> 
>> I have a tuple of types, I want a template that evaluates to the most
>> specialized base type of all of them. I'll be using it for classes
>> but for other cases it just needs to do something sane (erroring out
>> would do).
>> 
>> No point in reinventing the wheel so, anyone have such a template
>> laying around?
>> 
> tango.core.Tuple and std.typetuple have templates called MostDerived
> and DerivedToFront, these might be helpful?
>

I might be able to use somthing like that as a starting point but what I 
want is this

class A {}
 class B : A {}
 class C : A {}
  class D : C {}
  class E : C {}
class F {}

CCT!(E, D) // == C
CCT!(E, C) // == C
CCT!(E, B) // == A
CCT!(E, A) // == A
CCT!(E, F) // == object




More information about the Digitalmars-d-learn mailing list