
my closest attempt is this: #include <iostream> #include <tr1/functional> template <typename T> void callback_1(T value) { std::cout << __PRETTY_FUNCTION__ << std::endl; } template <typename T> void callback_2(T value) { std::cout << __PRETTY_FUNCTION__ << std::endl; } template <typename T, void (*FunctionPointer) (T)> struct function_template_wrapper { typedef void (*FunctionPointerType) (T); static FunctionPointerType function_pointer; static std::tr1::function<void (T)> function() { return std::tr1::function<void (T)>(FunctionPointer); } }; template <typename T, void (*FunctionPointer) (T)> typename function_template_wrapper<T, FunctionPointer>::FunctionPointerType function_template_wrapper<T, FunctionPointer>::function_pointer = FunctionPointer; template <typename T> struct callback_1_wrapper : public function_template_wrapper<T, callback_1<T> > {}; template <typename T> struct callback_2_wrapper : public function_template_wrapper<T, callback_2<T> > {}; template <template <typename> class function_template_wrapper> void set_callback() { function_template_wrapper<int>::function()(int()); function_template_wrapper<double>::function()(int()); function_template_wrapper<float>::function()(int()); } int main(int argc, char* argv[]) { set_callback<callback_1_wrapper>(); set_callback<callback_2_wrapper>(); } -- Ares Lagae Computer Graphics Research Group, Katholieke Universiteit Leuven http://www.cs.kuleuven.be/~ares/