diff --git a/include/sot/core/flags.hh b/include/sot/core/flags.hh index c4d796271ed86cabd11bcdb65a7234f66cf698fd..e233969d488e56145f6a59a1ee63dc45c63d4748 100644 --- a/include/sot/core/flags.hh +++ b/include/sot/core/flags.hh @@ -37,7 +37,7 @@ protected: public: Flags(const bool &b = false); Flags(const char *flags); - Flags(std::vector<bool> &&flags); + Flags(const std::vector<bool> &flags); void add(const bool &b); diff --git a/src/python-module.cc b/src/python-module.cc index da50ed294b3dff3f549a9870b198356061c61f83..baabaaa40af6da4fcbda3326e094c0bcef7092c9 100644 --- a/src/python-module.cc +++ b/src/python-module.cc @@ -50,7 +50,16 @@ BOOST_PYTHON_MODULE(wrap) using dgs::Flags; bp::class_<Flags>("Flags", bp::init<>()) .def(bp::init<const char*>()) - //TODO .def(bp::init<std::vector<bool>&& >()) + .def("__init__", bp::make_constructor(+[](bp::list bools) { + std::vector<bool> flags (bp::len(bools)); + for (std::size_t i = 0; i < flags.size(); ++i) flags[i] = bp::extract<bool>(bools[i]); + return new Flags(flags); + })) + .def("__init__", bp::make_constructor(+[](bp::tuple bools) { + std::vector<bool> flags (bp::len(bools)); + for (std::size_t i = 0; i < flags.size(); ++i) flags[i] = bp::extract<bool>(bools[i]); + return new Flags(flags); + })) .def("add", &Flags::add) .def("set", &Flags::set) .def("unset", &Flags::unset) diff --git a/src/sot/flags.cpp b/src/sot/flags.cpp index c32bba73289d9aa2d2dd0aa29b1411fd92280fe1..29a5642d64991428966485650d4ea0c1c241ab18 100644 --- a/src/sot/flags.cpp +++ b/src/sot/flags.cpp @@ -47,7 +47,7 @@ Flags::Flags(const char *_flags) } } -Flags::Flags(std::vector<bool> &&_flags) +Flags::Flags(const std::vector<bool> &_flags) : flags(_flags), outOfRangeFlag(false) {} Flags::operator bool(void) const {