From f97cf54db7a6f7642cc9fd122f23c4396c39bcf0 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Mon, 23 Sep 2019 13:52:58 -0700 Subject: ext: Updated Pybind11 to version 2.4.1. This updates Pybind11 from version 2.2.1 to version 2.4.1. This fixes warning/error received when "" is used when compiling using c++14 with clang. It should be noted that "ext/pybind11/include/pybind11/std.h" has been changed to include a fix added by commit ba42457254cc362eddc099f22b60d469cc6369e0. This is necessary to avoid build errors. Built: Linux (gcc, c++11) and MacOS (clang, c++14). Tested: Ran quick tests for X86, ARM, and RISC-V. Deprecates: https://gem5-review.googlesource.com/c/public/gem5/+/21019 Change-Id: Ie9783511cb6be50136076a55330e645f4f36d075 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21119 Reviewed-by: Jason Lowe-Power Reviewed-by: Andreas Sandberg Maintainer: Jason Lowe-Power Maintainer: Andreas Sandberg Tested-by: kokoro --- ext/pybind11/tests/test_stl.cpp | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'ext/pybind11/tests/test_stl.cpp') diff --git a/ext/pybind11/tests/test_stl.cpp b/ext/pybind11/tests/test_stl.cpp index 7d53e9c18..207c9fb2b 100644 --- a/ext/pybind11/tests/test_stl.cpp +++ b/ext/pybind11/tests/test_stl.cpp @@ -8,8 +8,12 @@ */ #include "pybind11_tests.h" +#include "constructor_stats.h" #include +#include +#include + // Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14 #if PYBIND11_HAS_VARIANT using std::variant; @@ -32,6 +36,8 @@ struct visit_helper { }} // namespace pybind11::detail #endif +PYBIND11_MAKE_OPAQUE(std::vector>); + /// Issue #528: templated constructor struct TplCtorClass { template TplCtorClass(const T &) { } @@ -57,6 +63,10 @@ TEST_SUBMODULE(stl, m) { static std::vector lvv{2}; m.def("cast_ptr_vector", []() { return &lvv; }); + // test_deque + m.def("cast_deque", []() { return std::deque{1}; }); + m.def("load_deque", [](const std::deque &v) { return v.at(0) == 1 && v.at(1) == 2; }); + // test_array m.def("cast_array", []() { return std::array {{1 , 2}}; }); m.def("load_array", [](const std::array &a) { return a[0] == 1 && a[1] == 2; }); @@ -235,4 +245,40 @@ TEST_SUBMODULE(stl, m) { // test_stl_pass_by_pointer m.def("stl_pass_by_pointer", [](std::vector* v) { return *v; }, "v"_a=nullptr); + + // #1258: pybind11/stl.h converts string to vector + m.def("func_with_string_or_vector_string_arg_overload", [](std::vector) { return 1; }); + m.def("func_with_string_or_vector_string_arg_overload", [](std::list) { return 2; }); + m.def("func_with_string_or_vector_string_arg_overload", [](std::string) { return 3; }); + + class Placeholder { + public: + Placeholder() { print_created(this); } + Placeholder(const Placeholder &) = delete; + ~Placeholder() { print_destroyed(this); } + }; + py::class_(m, "Placeholder"); + + /// test_stl_vector_ownership + m.def("test_stl_ownership", + []() { + std::vector result; + result.push_back(new Placeholder()); + return result; + }, + py::return_value_policy::take_ownership); + + m.def("array_cast_sequence", [](std::array x) { return x; }); + + /// test_issue_1561 + struct Issue1561Inner { std::string data; }; + struct Issue1561Outer { std::vector list; }; + + py::class_(m, "Issue1561Inner") + .def(py::init()) + .def_readwrite("data", &Issue1561Inner::data); + + py::class_(m, "Issue1561Outer") + .def(py::init<>()) + .def_readwrite("list", &Issue1561Outer::list); } -- cgit v1.2.3