I got a simple class which just wraps a function call to a classes method. When compiling (Using Visual Studio 2013) I get the error message:
Error 2 error C2664: 'Sleipnir::Core::Delegate::Delegate(const Sleipnir::Core::Delegate &)' : cannot convert argument 2 from 'void (__cdecl *)(void *const ,int &&)' to 'void (__cdecl *)(void *const ,int &&)' d:\programmieren\delegate\delegate\delegate.h 29 1 Delegate
which is not really helpful.
My code:
template<typename T>
class Delegate;
template<typename R, typename... A>
class Delegate<R(A...)>
{
using TFunc = R(*)(void* const, A&&...);
private:
Delegate(void* const obj, TFunc stub)
: _objectPtr(obj),
_stubPtr(stub){}
public:
Delegate(R(*const funcPtr)(A...))
: Delegate(nullptr, functionStub<R(*)(A...)>)
{
}
private:
template <R(*funcPtr)(A...)>
static R functionStub(void* const, A&&... args)
{
return funcPtr(::std::forward<A>(args)...);
}
private:
void* _objectPtr;
TFunc _stubPtr;
};
anyone got an idea why this happens, or how to fix it?