OK, I have an idea of what I might do:
I'm planning on making a Event handling system, and this is how I will connect events to functions and be able to send any type of data. This is the basic idea:
#include <iostream>
template <class T> T *from(void *data)
{
return (T *)data;
}
template <class T> void *to(T data)
{
return (void *)data;
}
void foo(void *data)
{
const char *test = from <const char> (data);
std::cout << test << std::endl;
}
void call_function(void *data, void(*function)(void*))
{
function(data);
}
int main()
{
const char *test = "Hello";
call_function(to <const char *> (test), foo);
std::cin.get();
return 0;
}
This works just fine, but is it really a viable option in practise?