In the following code, class template HANDLER
is supposed to accept one template parameter F
and one template template parameter P<R, S>
. The base class IMPLEMENTATION
is dependent to the parameters R
and S
. The way I declare class template HANDLER
, I must pass the template arguments F
,P
, R
and S
individually in ‘HANDLER’ template list (see class BAR
constructor). Isn’t there a way to pass class template ‘P<R, S>’ as a single parameter in the ‘HANDLER’ template list (see comment below class ‘BAR’ constructor) and still treat ‘R’ and ‘S’ as template arguments in the ‘HANDLER’ class? Thank you in advance, I am still new to C++ templates.
template <typename R, typename S> class IMPLEMENTATION{
public:
};
template <typename F, template <typename, typename> class P, typename R, typename S> class HANDLER : public IMPLEMENTATION<R, S>{
private:
F object;
public:
HANDLER(const F& object) : object(object){}
};
template <typename R, typename S> class BAR{
private:
IMPLEMENTATION<R, S>* implementation;
public:
template <typename F> BAR(const F& object):implementation(new HANDLER<F, BAR ,R, S>(object)){}
/*template <typename F> BAR(const F& object):implementation(new HANDLER<F, BAR<R,S>>(object)){}*/
};