diff options
author | Miodrag Milanović <mmicko@gmail.com> | 2021-01-02 11:16:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-02 11:16:49 +0100 |
commit | 9b9628047c01a970cfe20f83f2b7129ed109440d (patch) | |
tree | 1db418e9a889dc6fbe6199c5259aac9bd8cbb32f /3rdparty/pybind11/tests/test_smart_ptr.cpp | |
parent | c6cdf30501dcb2da01361229dd66a05dad73a132 (diff) | |
parent | 61b07bc9a664d6a88b85aae99f9756d7569688a9 (diff) | |
download | nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.tar.gz nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.tar.bz2 nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.zip |
Merge pull request #549 from YosysHQ/update
Update pybind11 version and fix for future python versions
Diffstat (limited to '3rdparty/pybind11/tests/test_smart_ptr.cpp')
-rw-r--r-- | 3rdparty/pybind11/tests/test_smart_ptr.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/3rdparty/pybind11/tests/test_smart_ptr.cpp b/3rdparty/pybind11/tests/test_smart_ptr.cpp index 87c9be8c..60c2e692 100644 --- a/3rdparty/pybind11/tests/test_smart_ptr.cpp +++ b/3rdparty/pybind11/tests/test_smart_ptr.cpp @@ -27,7 +27,8 @@ namespace pybind11 { namespace detail { struct holder_helper<ref<T>> { static const T *get(const ref<T> &p) { return p.get_ptr(); } }; -}} +} // namespace detail +} // namespace pybind11 // The following is not required anymore for std::shared_ptr, but it should compile without error: PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>); @@ -97,9 +98,9 @@ TEST_SUBMODULE(smart_ptr, m) { class MyObject1 : public Object { public: MyObject1(int value) : value(value) { print_created(this, toString()); } - std::string toString() const { return "MyObject1[" + std::to_string(value) + "]"; } + std::string toString() const override { return "MyObject1[" + std::to_string(value) + "]"; } protected: - virtual ~MyObject1() { print_destroyed(this); } + ~MyObject1() override { print_destroyed(this); } private: int value; }; @@ -207,7 +208,7 @@ TEST_SUBMODULE(smart_ptr, m) { class MyObject4b : public MyObject4a { public: MyObject4b(int i) : MyObject4a(i) { print_created(this); } - ~MyObject4b() { print_destroyed(this); } + ~MyObject4b() override { print_destroyed(this); } }; py::class_<MyObject4b, MyObject4a>(m, "MyObject4b") .def(py::init<int>()); @@ -291,7 +292,8 @@ TEST_SUBMODULE(smart_ptr, m) { ~C() { print_destroyed(this); } }; py::class_<C, custom_unique_ptr<C>>(m, "TypeWithMoveOnlyHolder") - .def_static("make", []() { return custom_unique_ptr<C>(new C); }); + .def_static("make", []() { return custom_unique_ptr<C>(new C); }) + .def_static("make_as_object", []() { return py::cast(custom_unique_ptr<C>(new C)); }); // test_holder_with_addressof_operator struct TypeForHolderWithAddressOf { @@ -337,7 +339,9 @@ TEST_SUBMODULE(smart_ptr, m) { // test_shared_ptr_gc // #187: issue involving std::shared_ptr<> return value policy & garbage collection struct ElementBase { - virtual ~ElementBase() { } /* Force creation of virtual table */ + virtual ~ElementBase() = default; /* Force creation of virtual table */ + ElementBase() = default; + ElementBase(const ElementBase&) = delete; }; py::class_<ElementBase, std::shared_ptr<ElementBase>>(m, "ElementBase"); |