So, suppose I have a class containing a functional object, and in the constructor call I pass arguments that will be passed to the functional object after some time. Sort of:
class Binder{ public: Binder(functional_object, listOfParameters); callFunctionalObject();
Prior to C ++ 11, I could not use Variadic templates, so one could do:
struct none{}; template <typename T1, typename T2=none, typename T3=none> class Binder{ public: Binder(T1 functionalObject, T2 arg1=none(), T3arg3=none()); void callFunctionalObject(); private: T1 m_functionalObject; T2 m_arg1; T3 m_arg2; };
Where callFunctionalobject can be implemented as follows:
template<typename T1, typename T2, typename T3> void Binder<T1,T2,T3>::callFunctionalObject(){ callImpl(m_functionalObject, m_arg1, m_arg2); }
and callImpl will be overloaded to recognize objects of type none to pass the required number of arguments to the function object.
Now switching to C ++ 11 I donβt know how to realize the fact that in a private section I have members to which I have direct access.
Can someone explain to me how I can do the same with C ++ 11 or C ++ 14?
source share