I have a template class
template <T>
class class1
{
template< typename T1, typename T2>
void func1 ()
{ // do somthing }
template< typename T1>
void func2 ()
{ //do something }
};
class class2
{
// Have three objects based on template type
public:
class2 ()
{
if (case1)
obj = class1<type1> ;
else if (case2)
obj = class1<type2>;
else if (case3)
obj = class1<type3>;
}
void fun1 ()
{ obj->func1(); } //calling class1 function based on template type
void func2 ()
{ obj->func2(); } //
typedef boost::variant <class1<Type1>, class1 <type2>, class1 <type3>> obj1;
obj1 obj;
};
How to call class1 functions using boost::variant. Can't create virtual class beacuse can't create templated virtual functions and I need to create a single object based on template type to avoid if else in each function.