mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-13 01:36:21 +00:00
stl_bind redesign & cleanup pass
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
example/example17.cpp -- Usage of stl_binders functions
|
||||
|
||||
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
|
||||
Copyright (c) 2016 Sergey Lyskov
|
||||
|
||||
All rights reserved. Use of this source code is governed by a
|
||||
BSD-style license that can be found in the LICENSE file.
|
||||
@@ -9,29 +9,28 @@
|
||||
|
||||
#include "example.h"
|
||||
|
||||
#include <pybind11/stl_binders.h>
|
||||
#include <pybind11/stl_bind.h>
|
||||
|
||||
|
||||
class A {
|
||||
class El {
|
||||
public:
|
||||
A() = delete;
|
||||
A(int v) :a(v) {}
|
||||
El() = delete;
|
||||
El(int v) : a(v) { }
|
||||
|
||||
int a;
|
||||
};
|
||||
|
||||
|
||||
std::ostream & operator<<(std::ostream &s, A const&v) {
|
||||
s << "A{" << v.a << '}';
|
||||
std::ostream & operator<<(std::ostream &s, El const&v) {
|
||||
s << "El{" << v.a << '}';
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void init_ex17(py::module &m) {
|
||||
pybind11::class_<A>(m, "A")
|
||||
pybind11::class_<El>(m, "El")
|
||||
.def(pybind11::init<int>());
|
||||
|
||||
pybind11::vector_binder<int>(m, "VectorInt");
|
||||
pybind11::bind_vector<int>(m, "VectorInt");
|
||||
|
||||
pybind11::vector_binder<A>(m, "VectorA");
|
||||
pybind11::bind_vector<El>(m, "VectorEl");
|
||||
|
||||
pybind11::bind_vector<std::vector<El>>(m, "VectorVectorEl");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user