I am trying to find a way to deal with some legacy code. There is a templated class which I would like to specialize the constructor to pass different arguments to its base when instantiated with a certain parameter.
template<typename T, typename U>
class A : public U {
public:
A(T &t, bool b);
// Other member functions
}
template<typename T, typename U>
A<T, U>::A(T &t, bool b)
: U(t, b) {}
I need to change thebehavior of this constructor when U is of a certain (templated) class.
template<typename Z>
class S;
template<typename T>
template<typename Z>
A<T, S<Z>>::A(T &t, bool b)
: S<Z>(t, b, false) {}
Is this possible? I know that class template specializations cannot be done without redefining a new class. But I would rather only specialize this behavior, and not any other member functions of this class U.
Aucun commentaire:
Enregistrer un commentaire