Is it possible to have optional template parameter in C++ , for example
template < class T, class U, class V>
class Test {
};
Here I want user to use this class either with V
or without V
Is following possible
Test<int,int,int> WithAllParameter
Test<int,int> WithOneMissing
If Yes how to do this.
You can have default template arguments, which are sufficient for your purposes:
template<class T, class U = T, class V = U>
class Test
{ };
Now the following work:
Test<int> a; // Test<int, int, int>
Test<double, float> b; // Test<double, float, float>