www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Why can't templatized classes be aliased ?

reply "KeyboardRider" <KeyboardRider nowhere.com> writes:
with these simple types:

class Implementator1(T){}
class Implementator2(T){}
class Implementator3(T){}

version(1)
{
   class ChosenImplementator(T): Implementator1!T{}
}

version(2)
{
   class ChosenImplementator(T): Implementator3!T{}
}

version(All)
{
   class Foo(T)
   {
      ChosenImplementator!T Bar;
   }
}

Why isn't it possible, technically, to alias a template ?
(such like that:)

version(1)
{
   alias (Implementator1(T)) ChosenImplementator(T);
}

version(2)
{
   alias (Implementator2(T)) ChosenImplementator(T);
}

which would avoid to polute a templatized class with some 
compiler switches.
Would aliasing template make sense ?
May 10 2013
next sibling parent reply "anonymous" <anonymous example.com> writes:
On Friday, 10 May 2013 at 15:53:25 UTC, KeyboardRider wrote:
 Why isn't it possible, technically, to alias a template ?
 (such like that:)

 version(1)
 {
   alias (Implementator1(T)) ChosenImplementator(T);
 }
alias Implementator1 ChosenImplementator;
May 10 2013
parent "KeyboardRider" <KeyboardRider nowhere.com> writes:
On Friday, 10 May 2013 at 15:57:48 UTC, anonymous wrote:
 On Friday, 10 May 2013 at 15:53:25 UTC, KeyboardRider wrote:
 Why isn't it possible, technically, to alias a template ?
 (such like that:)

 version(1)
 {
  alias (Implementator1(T)) ChosenImplementator(T);
 }
alias Implementator1 ChosenImplementator;
All right thx. Nothing else to add. ;)
May 10 2013
prev sibling parent "Daniel Murphy" <yebblies nospamgmail.com> writes:
"KeyboardRider" <KeyboardRider nowhere.com> wrote in message 
news:vabffcdkuarjzbsivkmc forum.dlang.org...
 with these simple types:

 class Implementator1(T){}
 class Implementator2(T){}
 class Implementator3(T){}

 version(1)
 {
   class ChosenImplementator(T): Implementator1!T{}
 }

 version(2)
 {
   class ChosenImplementator(T): Implementator3!T{}
 }

 version(All)
 {
   class Foo(T)
   {
      ChosenImplementator!T Bar;
   }
 }

 Why isn't it possible, technically, to alias a template ?
 (such like that:)

 version(1)
 {
   alias (Implementator1(T)) ChosenImplementator(T);
 }

 version(2)
 {
   alias (Implementator2(T)) ChosenImplementator(T);
 }

 which would avoid to polute a templatized class with some compiler 
 switches.
 Would aliasing template make sense ?
Or even template ChosenImplementator(T) { alias ChosenImplementator = Implementator1!T; }
May 10 2013