stl_bind redesign & cleanup pass

This commit is contained in:
Wenzel Jakob
2016-05-15 20:50:38 +02:00
parent 26aca3d8ad
commit 25c03cecfa
9 changed files with 384 additions and 289 deletions

View File

@@ -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");
}