2016-05-07 04:26:19 +00:00
|
|
|
/*
|
2016-05-08 23:31:55 +00:00
|
|
|
example/example17.cpp -- Usage of stl_binders functions
|
2016-05-07 04:26:19 +00:00
|
|
|
|
2016-05-15 18:50:38 +00:00
|
|
|
Copyright (c) 2016 Sergey Lyskov
|
2016-05-07 04:26:19 +00:00
|
|
|
|
|
|
|
All rights reserved. Use of this source code is governed by a
|
|
|
|
BSD-style license that can be found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "example.h"
|
|
|
|
|
2016-05-15 18:50:38 +00:00
|
|
|
#include <pybind11/stl_bind.h>
|
2016-05-07 04:26:19 +00:00
|
|
|
|
2016-05-15 18:50:38 +00:00
|
|
|
class El {
|
2016-05-07 04:26:19 +00:00
|
|
|
public:
|
2016-05-15 18:50:38 +00:00
|
|
|
El() = delete;
|
|
|
|
El(int v) : a(v) { }
|
2016-05-08 23:31:55 +00:00
|
|
|
|
|
|
|
int a;
|
2016-05-07 04:26:19 +00:00
|
|
|
};
|
|
|
|
|
2016-05-15 18:50:38 +00:00
|
|
|
std::ostream & operator<<(std::ostream &s, El const&v) {
|
|
|
|
s << "El{" << v.a << '}';
|
2016-05-08 23:31:55 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_ex17(py::module &m) {
|
2016-05-15 18:50:38 +00:00
|
|
|
pybind11::class_<El>(m, "El")
|
2016-05-08 23:31:55 +00:00
|
|
|
.def(pybind11::init<int>());
|
|
|
|
|
2016-05-16 10:14:25 +00:00
|
|
|
pybind11::bind_vector<unsigned int>(m, "VectorInt");
|
2016-05-30 09:28:21 +00:00
|
|
|
pybind11::bind_vector<bool>(m, "VectorBool");
|
2016-05-15 18:50:38 +00:00
|
|
|
|
|
|
|
pybind11::bind_vector<El>(m, "VectorEl");
|
2016-05-07 04:26:19 +00:00
|
|
|
|
2016-05-15 18:50:38 +00:00
|
|
|
pybind11::bind_vector<std::vector<El>>(m, "VectorVectorEl");
|
2016-05-07 04:26:19 +00:00
|
|
|
}
|