23 using StringList = std::vector<std::string, std::allocator<std::string>>;
27 py::class_<StringList>(
m,
"StringList")
29 .def(
"pop_back", &StringList::pop_back)
31 .def(
"push_back", (
void(
StringList::*)(
const std::string &)) & StringList::push_back)
32 .def(
"back", (std::string & (
StringList::*) ()) & StringList::back)
33 .def(
"__len__", [](
const StringList &
v) {
return v.size(); })
37 py::keep_alive<0, 1>());
39 class ClassWithSTLVecProperty {
43 py::class_<ClassWithSTLVecProperty>(
m,
"ClassWithSTLVecProperty")
45 .def_readwrite(
"stringList", &ClassWithSTLVecProperty::stringList);
47 m.def(
"print_opaque_list", [](
const StringList &
l) {
48 std::string
ret =
"Opaque list: [";
50 for (
const auto &entry : l) {
61 m.def(
"return_void_ptr", []() {
return (
void *) 0x1234; });
62 m.def(
"get_void_ptr_value", [](
void *ptr) {
return reinterpret_cast<std::intptr_t>(ptr); });
63 m.def(
"return_null_str", []() {
return (
char *)
nullptr; });
64 m.def(
"get_null_str_value", [](
char *ptr) {
return reinterpret_cast<std::intptr_t>(ptr); });
66 m.def(
"return_unique_ptr", []() -> std::unique_ptr<StringList> {
68 result->push_back(
"some value");
69 return std::unique_ptr<StringList>(
result);
73 py::class_<IntFloat>(
m,
"IntFloat")
EIGEN_CONSTEXPR Index first(const T &x) EIGEN_NOEXCEPT
static const Line3 l(Rot3(), 1, 1)
Array< int, Dynamic, 1 > v
TEST_SUBMODULE(opaque_types, m)
PYBIND11_MAKE_OPAQUE(std::vector< std::string, std::allocator< std::string >>)
iterator make_iterator(Iterator &&first, Sentinel &&last, Extra &&...extra)
Makes a python iterator from a first and past-the-end C++ InputIterator.
std::vector< std::string, std::allocator< std::string > > StringList