how to pass pointer to boost.python function in python?
Dear all, I wraped a v_varray class into python by boost. I called it in python, most of its attributes work well. Only when I call a.push(1.0),it crashed due to not match type.The problem is that my input argument in c++ is float*(for passing an array) while python has no pointer type. How can I pass a variable in python to a.push() to make sure it work correctly? Many thanks for help! Javen /*************************running result in python:****************/
a.push(1.0) Traceback (most recent call last): File "<stdin>", line 1, in ? Boost.Python.ArgumentError: Python argument types in array_floatstar.push(array_floatstar, float) did not match C++ signature: push(v_array
{lvalue}, float*)
/*************************v_array def in stack.h:****************/
#ifndef _STACK_H
#define _STACK_H
#include
"Qinfeng(Javen) Shi "
Dear all,
I wraped a v_varray class into python by boost. I called it in python, most of its attributes work well. Only when I call a.push(1.0),it crashed due to not match type.
For the record, that's not a crash.
The problem is that my input argument in c++ is float*(for passing an array) while python has no pointer type.
That's one way to look at it.
How can I pass a variable in python to a.push() to make sure it work correctly?
Depends what you mean by "work correctly." You need to decide what
semantics you want. If you want your float to be treated as an array
of one element, you could use a "thin wrapper":
void push(v_array
participants (2)
-
David Abrahams
-
Qinfeng(Javen) Shi