(This question follows from this answer )
I am trying to adapt a trampoline function that currently goes through a variable number of arguments.
I would like it to convert any PyObject* pyob to Object{pyob} , but forward all other arguments through.
So (void* self, int, PyObject*, float) → (int, Object, float)
In this example, the first argument to self is removed. It always happens. Of the remaining arguments, one of them is of type PyObject * and, therefore, requires conversion to Object.
Here is the function:
template <typename T, T t> struct trap; template <typename R, typename... Args, R(Base::*t)(Args...)> struct trap<R(Base::*)(Args...), t> { static R call(void* s, Args... args) { std::cout << "trap:" << typeid(t).name() << std::endl; try { return (get_base(s)->*t)(std::forward<Args>(args)...); } catch (...) { std::cout << "CAUGHT" << std::endl; return std::is_integral<R>::value ? static_cast<R>(-42) : static_cast<R>(-3.14); } } };
This does not seem to be forwarding arguments. I think he is making a copy of each argument. I tried:
call(void* s, Args&&... args)
But this just causes compiler errors.
Full test case here
How can I fix a function to completely redirect all arguments except those of the type PyObject * that it should convert?