My best gues would be to store a DC pointer in your FreeList class and then use templated constructors to assign the correct type of thing to the DC pointer, sort of like:
class FreeList{public: template <class T> FreeList(const T value):_object(T) {}private: DC * _object;};
If not, perhaps you could get some inspiration from this code, slightly modified from the Functor class from Modern C++ Design:
#ifndef FUNCTOR_H#define FUNCTOR_H#include <cassert>#include "SmartPointer.h"class EmptyClass {};template <typename R, typename P1, typename P2, typename P3>class FunctorStorage{public: FunctorStorage() {} virtual ~FunctorStorage() {} virtual R Execute(P1, P2, P3) = 0;};template <typename R>class FunctorStorage<R, EmptyClass, EmptyClass, EmptyClass>{public: FunctorStorage() {} virtual ~FunctorStorage() {} virtual R Execute() = 0;};template <typename R, typename P1>class FunctorStorage<R, P1, EmptyClass, EmptyClass>{public: FunctorStorage() {} virtual ~FunctorStorage() {} virtual R Execute(P1) = 0;};template <typename R, typename P1, typename P2>class FunctorStorage<R, P1, P2, EmptyClass>{public: FunctorStorage() {} virtual ~FunctorStorage() {} virtual R Execute(P1, P2) = 0;};template <typename R, typename P1, typename P2, typename P3, typename F>class FunctionPointer : public FunctorStorage<R, P1, P2, P3>{public: FunctionPointer(const F & func):_function(func) {} virtual ~FunctionPointer() {} R Execute() {return _function();} R Execute(P1 param1) {return _function(param1);} R Execute(P1 param1, P2 param2) {return _function(param1, param2);} R Execute(P1 param1, P2 param2, P3 param3) {return _function(param1, param2, param3);}private: F _function;};template <typename R, typename P1, typename P2, typename P3, typename F, class O>class MemberPointer : public FunctorStorage<R, P1, P2, P3>{public: MemberPointer(const O & object, const F & func):_function(func), _object(object) {} virtual ~MemberPointer() {} R Execute() {return ((*_object).*_function)();} R Execute(P1 param1) {return ((*_object).*_function)(param1);} R Execute(P1 param1, P2 param2) {return ((*_object).*_function)(param1, param2);} R Execute(P1 param1, P2 param2, P3 param3) {return ((*_object).*_function)(param1, param2, param3);}private: F _function; O _object;};//This is where the magic happenstemplate <typename R, typename P1 = EmptyClass, typename P2 = EmptyClass, typename P3 = EmptyClass>class Functor{public: Functor() {} template <typename F> Functor(F value):_function(new FunctionPointer<R, P1, P2, P3, F>(value)) {} template <typename F, class O> Functor(const O & object, F func):_function(new MemberPointer<R, P1, P2, P3, F, O>(object, func)) {} R operator()() {assert(_function != 0); return _function->Execute();} R operator()(P1 param1) {assert(_function != 0); return _function->Execute(param1);} R operator()(P1 param1, P2 param2) {assert(_function != 0); return _function->Execute(param1, param2);} R operator()(P1 param1, P2 param2, P3 param3) {assert(_function != 0); return _function->Execute(param1, param2, param3);} operator bool() const {return _function != 0;} //Used for testing if we have a function stored void Clear() {_function = 0;} template <typename F> void Set(F value) {_function = new FunctionPointer<R, P1, P2, P3, F>(value);} //smart_ptr will automatically free up old stuff template <typename F, class O> void Set(const O & object, F func) {_function = new MemberPointer<R, P1, P2, P3, F, O>(object, func);}private: smart_ptr<FunctorStorage<R, P1, P2, P3> > _function;};#endif
Now, the beautiful thing about this code is that C++ does not instantiate member functions for templates until they are used, which allows you to get away with defining loads of functions that you may not actually need.
Any way, I hope there's something here to help you.