N
Nan Li
Hello,
I have the following code now.
enum T1
{ A, B, C };
enum T2
{ D, E, F };
class Base
{
};
template < T1, T2 >
class Derived : public Base
{
} ;
Base * build( T1 t1, T2 t2 )
{
if ( t1 == A and t2 == D )
{
return new Derived<A,D>();
}
if ( t1 == A and t2 == E )
{
return new Derived<A,E>();
}
if ( t1 == A and t2 == F )
{
return new Derived<A,F>();
}
// ..... all the combinations here
}
I really hate to list all the T1-T2 combinations in the 'build'
functions. Is there any better way to code this? t1 and t2 are known
only at run time.
Thanks a lot !
I have the following code now.
enum T1
{ A, B, C };
enum T2
{ D, E, F };
class Base
{
};
template < T1, T2 >
class Derived : public Base
{
} ;
Base * build( T1 t1, T2 t2 )
{
if ( t1 == A and t2 == D )
{
return new Derived<A,D>();
}
if ( t1 == A and t2 == E )
{
return new Derived<A,E>();
}
if ( t1 == A and t2 == F )
{
return new Derived<A,F>();
}
// ..... all the combinations here
}
I really hate to list all the T1-T2 combinations in the 'build'
functions. Is there any better way to code this? t1 and t2 are known
only at run time.
Thanks a lot !