T
Oke das Problem wurde komplett gelöst, basic_object.cpp ist lauffähig sobald man den Funktionsparameter von FunctionT & f in FunctionT f umwandelt ...
#include <iostream>
template <class T, class ObjectT, class FunctionT>
struct obj_caller;
template <class T>
struct basic_object
{
inline T const& derived() const
{ return *static_cast<T const*>(this); }
template <class ObjectT, class FunctionT>
inline obj_caller<T, ObjectT, FunctionT> operator()(ObjectT *obj, FunctionT v) const
{
return obj_caller<T, ObjectT, FunctionT>(derived(), obj, v);
}
};
template <class T, class ObjectT, class FunctionT>
struct obj_caller : public basic_object<obj_caller<T,ObjectT, FunctionT> >
{
T caller;
ObjectT *callee;
FunctionT function;
obj_caller(const T &m, ObjectT *c, FunctionT f) : caller(m), callee(c), function(f) {}
void exec()
{
caller.do_call(callee,function);
}
};
template <char v>
struct example : public basic_object<example < v> >
{
template <class ObjectT, class FunctionT>
inline void do_call(ObjectT *obj, FunctionT f)
{
(obj->*f)(v);
}
};
struct receiver
{
example<'a'> sender;
void callme(char value)
{
std::cout << "Got called with " << value << std::endl;
}
void run()
{
obj_caller<example<'a'>, receiver, void (receiver::*)(char) > foo = sender(this, &receiver::callme);
foo.exec();
sender(this, &receiver::callme).exec();
}
};
int main()
{
receiver obj;
obj.run();
return 0;
}
... vielen Dank an MrN