I would like to create a base class that will be inherited by other objects so that they can be stored in the same container. This base class will contain a templated method that defines the fuction as a setter or getter used for accessing a buffer in a multithreaded system. I want to do something like this guy did but not really sure how to implement Linky. Also I would like to be able to have the function in the base to be virtual and define the functionality in the dervived classes, I know you can't actually have a virtual template function but is there a way to code it in a way that it acts like the concept of a virtual template function. Below is a crude example on how I would like the layout to be. The do_work method with be called through a callback. The callback is passed to the thread as a argument.
class A {
template<typename R, typename P>
virtual R do_work(P param) = 0;
}
class B : public A {
template<void,int> // declare as setter
R do_work(P param){/*do something*/ return R;}
}
class C : public A {
template<int,void> // declare as getter
R do_work(P param){/*do something*/ return R;}
}