my closest attempt is this:
#include <iostream>
#include
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
struct function_template_wrapper
{
typedef void (*FunctionPointerType) (T);
static FunctionPointerType function_pointer;
static std::tr1::function function() { return
std::tr1::function(FunctionPointer); }
};
template
typename function_template_wrapper::FunctionPointerType
function_template_wrapper::function_pointer =
FunctionPointer;
template <typename T> struct callback_1_wrapper : public
function_template_wrapper {};
template <typename T> struct callback_2_wrapper : public
function_template_wrapper {};
template
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();
set_callback();
}
--
Ares Lagae
Computer Graphics Research Group, Katholieke Universiteit Leuven
http://www.cs.kuleuven.be/~ares/