class template conflict
    Michelle Long 
    HappyDance321 at gmail.com
       
    Sun Dec 23 12:09:31 UTC 2018
    
    
  
class X
{
}
class X(int N) : X
{
}
Is there any real reason we can't do this?
It is very nice to be able to treat X like the base and X!n as a 
derived class.
Sure we can do
class X(int N) : X!0
{
    static if(N == 0)
    {
    }
}
but this is very ugly, in my code I always have to use X!0 as the 
basis!
I do not think there is any harm to allow this since the 
templated class always has to specify N. It is not like we can do
class X(int N = 0) : X
{
    static if(N == 0)
    {
    }
}
Actually we can, so... I don't see the point in not allowing the 
first case, they are logically equivalent. That static if is just 
ugly and it is defining the base class inside the derived class 
which seems unnatural.
    
    
More information about the Digitalmars-d-learn
mailing list