|
From: Nathan R. <zer...@ho...> - 2012-05-04 21:50:33
|
Oops, my mail client munged that again :(
Let me try again:
I'm having trouble using an std::vector as a data member of a class. Here is my header file:
#include <vector>
struct S
{
std::vector<int> v;
};
std::vector<int> foo();
S bar();
My interface file:
%module test
%{
#include "test.hpp"
%}
%include
"std_vector.i"
namespace std
{
%template(IntVec)
std::vector<int>;
}
%include "test.hpp"
I am making a PHP wrapper.
When I try to use a function that directly returns an std::vector, it works fine:
$v1 = test::foo();
However, when I try to use a function that returns an S object, and try
to access its
data member which is of type std::vector:
$s = test::bar();
$v2 = $s->v;
I get the following error at runtime:
PHP Fatal error: Class 'vectorT_int_t' not found in test.php on line 145
How can I fix this?
Thanks,
Nate
----------------------------------------
> From: zer...@ho...
> To: swi...@li...
> Subject: [php] using an std::vector as a data member in a struct
> Date: Wed, 2 May 2012 23:08:54 +0000
>
>
> Hi,
> I'm having trouble using an std::vector as a data member of a class. Here is my header file:
> #include <vector>struct S{ std::vector<int> v;};std::vector<int> foo();S bar();
>
> My interface file:
> %module test %{ #include "test.hpp" %} %include "std_vector.i"namespace std{ %template(IntVec) std::vector<int>;} %include "test.hpp"
> I am making a PHP wrapper.
> When I try to use a function that directly returns an std::vector, it works fine:
> $v1 = test::foo();
> However, when I try to use a function that returns an S object, and try to access itsdata member which is of type std::vector:
> $s = test::bar();var_dump($s);$v2 = $s->v;
> I get the following error at runtime:
> PHP Fatal error: Class 'vectorT_int_t' not found in test.php on line 145
> How can I fix this?
> Thanks,Nate
>
|