I would like to expose C++ code with a
std::vector<A>
to python. My
class A{};
does not have a comparison operator implemented. When I try
BOOST_PYTHON_MODULE(libmyvec)
{
using namespace boost::python;
class_<A>("A");
class_<std::vector<A> >("Avec")
.def(boost::python::vector_indexing_suite<std::vector<A> >());
}
I get an error about comparison operators. If I change the definition of A to
class A {
public:
bool operator==(const A& other) {return false;}
bool operator!=(const A& other) {return true;}
};
It works like a charm.
Why do I need to implement these comparison operators? Is there any way to use the vector_indexing_suite
without them?