From 10b5fbc3462f47897dcb0de23a5691718877b006 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Wed, 6 Oct 2021 10:26:46 -0400 Subject: [PATCH 01/21] Fix STL optional casting issue --- include/pybind11/stl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 2c017b4fef..5c0592f80d 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -252,8 +252,8 @@ template struct optional_caster { static handle cast(T_ &&src, return_value_policy policy, handle parent) { if (!src) return none().inc_ref(); - if (!std::is_lvalue_reference::value) { - policy = return_value_policy_override::policy(policy); + if (!std::is_lvalue_reference::value) { + policy = return_value_policy_override::policy(policy); } return value_conv::cast(*std::forward(src), policy, parent); } From 78de7cbfc09025898ef2617faebbf200d9cf6b1d Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 11:35:27 -0400 Subject: [PATCH 02/21] Add boost optional tests --- tests/test_stl.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 7e3363c5ea..27e5b9386b 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -20,9 +20,13 @@ #include // Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14 -#if defined(PYBIND11_HAS_VARIANT) +#if defined(PYBIND11_HAS_OPTIONAL) && defined(PYBIND11_HAS_VARIANT) +using std::optional; using std::variant; #elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910) +# include +# define PYBIND11_HAS_OPTIONAL 1 +using boost::optional; # include # define PYBIND11_HAS_VARIANT 1 using boost::variant; @@ -38,6 +42,9 @@ struct visit_helper { return boost::apply_visitor(args...); } }; + +template +struct type_caster> : optional_caster> {}; }} // namespace pybind11::detail #endif @@ -192,8 +199,8 @@ TEST_SUBMODULE(stl, m) { // test_optional m.attr("has_optional") = true; - using opt_int = std::optional; - using opt_no_assign = std::optional; + using opt_int = optional; + using opt_no_assign = optional; m.def("double_or_zero", [](const opt_int& x) -> int { return x.value_or(0) * 2; }); @@ -205,10 +212,10 @@ TEST_SUBMODULE(stl, m) { return x ? x->value : 42; }, py::arg_v("x", std::nullopt, "None")); - m.def("nodefer_none_optional", [](std::optional) { return true; }); + m.def("nodefer_none_optional", [](optional) { return true; }); m.def("nodefer_none_optional", [](const py::none &) { return false; }); - using opt_holder = OptionalHolder; + using opt_holder = OptionalHolder; py::class_(m, "OptionalHolder", "Class with optional member") .def(py::init<>()) .def_readonly("member", &opt_holder::member) @@ -279,7 +286,7 @@ TEST_SUBMODULE(stl, m) { m.def("tpl_ctor_map", [](std::unordered_map &) {}); m.def("tpl_ctor_set", [](std::unordered_set &) {}); #if defined(PYBIND11_HAS_OPTIONAL) - m.def("tpl_constr_optional", [](std::optional &) {}); + m.def("tpl_constr_optional", [](optional &) {}); #elif defined(PYBIND11_HAS_EXP_OPTIONAL) m.def("tpl_constr_optional", [](std::experimental::optional &) {}); #endif From 6377c24aef09f21fde37569f62f280b26afe2a62 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 11:42:16 -0400 Subject: [PATCH 03/21] Handle nullopt --- tests/test_stl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 27e5b9386b..ee09d37489 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -9,6 +9,7 @@ #include "pybind11_tests.h" #include "constructor_stats.h" +#include #include #ifndef PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL @@ -21,12 +22,14 @@ // Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14 #if defined(PYBIND11_HAS_OPTIONAL) && defined(PYBIND11_HAS_VARIANT) +using std::nullopt; using std::optional; using std::variant; #elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910) # include # define PYBIND11_HAS_OPTIONAL 1 using boost::optional; +using nullopt = boost::none; # include # define PYBIND11_HAS_VARIANT 1 using boost::variant; @@ -207,10 +210,10 @@ TEST_SUBMODULE(stl, m) { m.def("half_or_none", [](int x) -> opt_int { return x != 0 ? opt_int(x / 2) : opt_int(); }); m.def("test_nullopt", [](opt_int x) { return x.value_or(42); - }, py::arg_v("x", std::nullopt, "None")); + }, py::arg_v("x", nullopt, "None")); m.def("test_no_assign", [](const opt_no_assign &x) { return x ? x->value : 42; - }, py::arg_v("x", std::nullopt, "None")); + }, py::arg_v("x", nullopt, "None")); m.def("nodefer_none_optional", [](optional) { return true; }); m.def("nodefer_none_optional", [](const py::none &) { return false; }); From c8a0c60bd8a1cc8ab5b4af8f8114f097f769ce9b Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 11:43:44 -0400 Subject: [PATCH 04/21] Remove errant header --- tests/test_stl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index ee09d37489..23d7ce15ea 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -9,7 +9,6 @@ #include "pybind11_tests.h" #include "constructor_stats.h" -#include #include #ifndef PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL From 2cb63e31e9d486eed4a4f764ea42c4567753bea8 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 11:49:22 -0400 Subject: [PATCH 05/21] Add missing header --- tests/test_stl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 23d7ce15ea..30c9f7394a 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -25,6 +25,7 @@ using std::nullopt; using std::optional; using std::variant; #elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910) +# include # include # define PYBIND11_HAS_OPTIONAL 1 using boost::optional; From 4060677b629c92dafe12ac924da55daea58a8ae1 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 11:56:14 -0400 Subject: [PATCH 06/21] Try to fix type --- tests/test_stl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 30c9f7394a..76dfc9f511 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -29,7 +29,7 @@ using std::variant; # include # define PYBIND11_HAS_OPTIONAL 1 using boost::optional; -using nullopt = boost::none; +using nullopt = boost::none_t; # include # define PYBIND11_HAS_VARIANT 1 using boost::variant; From a9dcec52387c766cf8342eb30affc132d743c0f0 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 12:08:39 -0400 Subject: [PATCH 07/21] One last try --- tests/test_stl.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 76dfc9f511..d7e54b7660 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -28,8 +28,10 @@ using std::variant; # include # include # define PYBIND11_HAS_OPTIONAL 1 -using boost::optional; -using nullopt = boost::none_t; +template +using optional = boost::optional; +using nullopt_t = boost::none_t; +const nullopt_t nullopt = boost::none; # include # define PYBIND11_HAS_VARIANT 1 using boost::variant; From 99a80f5d46641646ac9e72bd3b40e0845b596c57 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 12:23:41 -0400 Subject: [PATCH 08/21] Add None caster --- tests/test_stl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index d7e54b7660..7c5320bb12 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -22,6 +22,7 @@ // Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14 #if defined(PYBIND11_HAS_OPTIONAL) && defined(PYBIND11_HAS_VARIANT) using std::nullopt; +using std::nullopt_t; using std::optional; using std::variant; #elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910) @@ -50,6 +51,8 @@ struct visit_helper { template struct type_caster> : optional_caster> {}; + +template<> struct type_caster : public void_caster {}; }} // namespace pybind11::detail #endif From af0fdae82be1afb489118ad208f3b443f4ddea7f Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 12:25:27 -0400 Subject: [PATCH 09/21] Make nullopt_t --- tests/test_stl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 7c5320bb12..86077cd2ed 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -52,7 +52,7 @@ struct visit_helper { template struct type_caster> : optional_caster> {}; -template<> struct type_caster : public void_caster {}; +template<> struct type_caster : public void_caster {}; }} // namespace pybind11::detail #endif From a864106776ce7114ec2643293d9a081bcb334dbb Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 12:49:13 -0400 Subject: [PATCH 10/21] See if bug reproduces --- include/pybind11/stl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 5c0592f80d..2c017b4fef 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -252,8 +252,8 @@ template struct optional_caster { static handle cast(T_ &&src, return_value_policy policy, handle parent) { if (!src) return none().inc_ref(); - if (!std::is_lvalue_reference::value) { - policy = return_value_policy_override::policy(policy); + if (!std::is_lvalue_reference::value) { + policy = return_value_policy_override::policy(policy); } return value_conv::cast(*std::forward(src), policy, parent); } From 9c5709b70bd3f825d145b5db80f64effb10fc979 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 12:56:54 -0400 Subject: [PATCH 11/21] Add bugfix back --- include/pybind11/stl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 2c017b4fef..5c0592f80d 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -252,8 +252,8 @@ template struct optional_caster { static handle cast(T_ &&src, return_value_policy policy, handle parent) { if (!src) return none().inc_ref(); - if (!std::is_lvalue_reference::value) { - policy = return_value_policy_override::policy(policy); + if (!std::is_lvalue_reference::value) { + policy = return_value_policy_override::policy(policy); } return value_conv::cast(*std::forward(src), policy, parent); } From d379c8c2c4ebb4e7e9d0408844779c0cd294ebdd Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 13:13:05 -0400 Subject: [PATCH 12/21] Add issue_3330 tests --- tests/test_stl.cpp | 19 +++++++++++++++++++ tests/test_stl.py | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 86077cd2ed..7a59724fee 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -228,6 +228,25 @@ TEST_SUBMODULE(stl, m) { .def(py::init<>()) .def_readonly("member", &opt_holder::member) .def("member_initialized", &opt_holder::member_initialized); + + // issue_3330 + enum class IssueKEnum { + k0 = 0, + k1 = 1, + }; + + struct BoostOptionalIssue { + optional value = IssueKEnum::k1; + }; + + py::enum_(m, "IssueKEnum").value("k0", IssueKEnum::k0).value("k1", IssueKEnum::k1); + + py::class_(m, "BoostOptionalIssue") + .def(py::init<>()) + .def_property_readonly( + "by_ref", [](BoostOptionalIssue &a) -> optional & { return a.value; }) + .def_property_readonly( + "by_copy", [](BoostOptionalIssue &a) -> optional { return a.value; }); #endif #ifdef PYBIND11_HAS_EXP_OPTIONAL diff --git a/tests/test_stl.py b/tests/test_stl.py index 3f63d6c3a4..037dbe7443 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -131,6 +131,10 @@ def test_optional(): mvalue = holder.member assert mvalue.initialized assert holder.member_initialized() + a = m.BoostOptionalIssue().by_ref() + assert a is not None + b = m.BoostOptionalIssue().by_copy() + assert b is not None @pytest.mark.skipif( From 849f7f5c9acbf8d903ec03688835b5a2f063d632 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 13:20:27 -0400 Subject: [PATCH 13/21] Whoops not callable --- tests/test_stl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_stl.py b/tests/test_stl.py index 037dbe7443..059742d77f 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -131,9 +131,9 @@ def test_optional(): mvalue = holder.member assert mvalue.initialized assert holder.member_initialized() - a = m.BoostOptionalIssue().by_ref() + a = m.BoostOptionalIssue().by_ref assert a is not None - b = m.BoostOptionalIssue().by_copy() + b = m.BoostOptionalIssue().by_copy assert b is not None From c33091fbe9585cb14a7c711823b45f803345bb9a Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 13:53:53 -0400 Subject: [PATCH 14/21] Refactor code --- tests/test_stl.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 7a59724fee..7dfc1e877a 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -19,13 +19,11 @@ #include #include -// Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14 -#if defined(PYBIND11_HAS_OPTIONAL) && defined(PYBIND11_HAS_VARIANT) +#if defined(PYBIND11_HAS_OPTIONAL) using std::nullopt; using std::nullopt_t; using std::optional; -using std::variant; -#elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910) +#elif defined(PYBIND11_TEST_BOOST) # include # include # define PYBIND11_HAS_OPTIONAL 1 @@ -33,6 +31,19 @@ template using optional = boost::optional; using nullopt_t = boost::none_t; const nullopt_t nullopt = boost::none; + +namespace pybind11 { namespace detail { +template +struct type_caster> : optional_caster> {}; + +template<> struct type_caster : public void_caster {}; +}} // namespace pybind11::detail +#endif + +// Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14 +#if defined(PYBIND11_HAS_VARIANT) +using std::variant; +#elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910) # include # define PYBIND11_HAS_VARIANT 1 using boost::variant; @@ -48,11 +59,6 @@ struct visit_helper { return boost::apply_visitor(args...); } }; - -template -struct type_caster> : optional_caster> {}; - -template<> struct type_caster : public void_caster {}; }} // namespace pybind11::detail #endif From 42955ba4b61a52eb222fac4acf54f3f282c4ad23 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 15:17:46 -0400 Subject: [PATCH 15/21] Stylefixes --- tests/test_stl.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 7dfc1e877a..f88e7ba735 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -47,7 +47,7 @@ using std::variant; # include # define PYBIND11_HAS_VARIANT 1 using boost::variant; - +/ namespace pybind11 { namespace detail { template struct type_caster> : variant_caster> {}; @@ -71,6 +71,13 @@ struct TplCtorClass { bool operator==(const TplCtorClass &) const { return true; } }; +// Issue: #3330 +// Needs to be here for MSVC +enum class IssueKEnum { + k0 = 0, + k1 = 1, +}; + namespace std { template <> struct hash { size_t operator()(const TplCtorClass &) const { return 0; } }; @@ -235,12 +242,7 @@ TEST_SUBMODULE(stl, m) { .def_readonly("member", &opt_holder::member) .def("member_initialized", &opt_holder::member_initialized); - // issue_3330 - enum class IssueKEnum { - k0 = 0, - k1 = 1, - }; - + // Issue: 3330 struct BoostOptionalIssue { optional value = IssueKEnum::k1; }; From f6a4cecc0ec09d4782234a645f0d17fda6a1d156 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 15:22:30 -0400 Subject: [PATCH 16/21] Fix typo --- tests/test_stl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index f88e7ba735..236b02959b 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -47,7 +47,7 @@ using std::variant; # include # define PYBIND11_HAS_VARIANT 1 using boost::variant; -/ + namespace pybind11 { namespace detail { template struct type_caster> : variant_caster> {}; From 6f9851ec5ab952e540049f93a8a72bd792d37189 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 15:24:11 -0400 Subject: [PATCH 17/21] Try to fix2 --- tests/test_stl.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 236b02959b..e4aab6310f 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -78,6 +78,11 @@ enum class IssueKEnum { k1 = 1, }; +// Issue: 3330 +struct BoostOptionalIssue { + optional value = IssueKEnum::k1; +}; + namespace std { template <> struct hash { size_t operator()(const TplCtorClass &) const { return 0; } }; @@ -242,11 +247,6 @@ TEST_SUBMODULE(stl, m) { .def_readonly("member", &opt_holder::member) .def("member_initialized", &opt_holder::member_initialized); - // Issue: 3330 - struct BoostOptionalIssue { - optional value = IssueKEnum::k1; - }; - py::enum_(m, "IssueKEnum").value("k0", IssueKEnum::k0).value("k1", IssueKEnum::k1); py::class_(m, "BoostOptionalIssue") From b720d49c04490e04ea1c81f3d28198eba8354a82 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 15:32:57 -0400 Subject: [PATCH 18/21] Try to simplify --- tests/test_stl.cpp | 49 +++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index e4aab6310f..bd54eb3b94 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -19,31 +19,19 @@ #include #include -#if defined(PYBIND11_HAS_OPTIONAL) +// Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14 +#if defined(PYBIND11_HAS_OPTIONAL) && defined(PYBIND11_HAS_VARIANT) using std::nullopt; using std::nullopt_t; using std::optional; -#elif defined(PYBIND11_TEST_BOOST) +using std::variant; +#elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910) # include # include # define PYBIND11_HAS_OPTIONAL 1 -template -using optional = boost::optional; +using optional = boost::optional; using nullopt_t = boost::none_t; const nullopt_t nullopt = boost::none; - -namespace pybind11 { namespace detail { -template -struct type_caster> : optional_caster> {}; - -template<> struct type_caster : public void_caster {}; -}} // namespace pybind11::detail -#endif - -// Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14 -#if defined(PYBIND11_HAS_VARIANT) -using std::variant; -#elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910) # include # define PYBIND11_HAS_VARIANT 1 using boost::variant; @@ -59,6 +47,11 @@ struct visit_helper { return boost::apply_visitor(args...); } }; + +template +struct type_caster> : optional_caster> {}; + +template<> struct type_caster : public void_caster {}; }} // namespace pybind11::detail #endif @@ -71,18 +64,6 @@ struct TplCtorClass { bool operator==(const TplCtorClass &) const { return true; } }; -// Issue: #3330 -// Needs to be here for MSVC -enum class IssueKEnum { - k0 = 0, - k1 = 1, -}; - -// Issue: 3330 -struct BoostOptionalIssue { - optional value = IssueKEnum::k1; -}; - namespace std { template <> struct hash { size_t operator()(const TplCtorClass &) const { return 0; } }; @@ -247,6 +228,16 @@ TEST_SUBMODULE(stl, m) { .def_readonly("member", &opt_holder::member) .def("member_initialized", &opt_holder::member_initialized); + // issue_3330 + enum class IssueKEnum { + k0 = 0, + k1 = 1, + }; + + struct BoostOptionalIssue { + optional value = IssueKEnum::k1; + }; + py::enum_(m, "IssueKEnum").value("k0", IssueKEnum::k0).value("k1", IssueKEnum::k1); py::class_(m, "BoostOptionalIssue") From c745a84bf8eca1dc6bcfa06392977505258d5c8d Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 15:36:57 -0400 Subject: [PATCH 19/21] Try again --- tests/test_stl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index bd54eb3b94..b0abfdfd2b 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -49,7 +49,7 @@ struct visit_helper { }; template -struct type_caster> : optional_caster> {}; +struct type_caster> : optional_caster> {}; template<> struct type_caster : public void_caster {}; }} // namespace pybind11::detail From c733c02f8f3e5eba847e7151c39f2bf629189740 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 15:38:11 -0400 Subject: [PATCH 20/21] Add template back in --- tests/test_stl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index b0abfdfd2b..9f19db2647 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -29,7 +29,7 @@ using std::variant; # include # include # define PYBIND11_HAS_OPTIONAL 1 -using optional = boost::optional; +template using optional = boost::optional; using nullopt_t = boost::none_t; const nullopt_t nullopt = boost::none; # include From 098e572b1a88e8ec947e729fc71006613c2b55b3 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 8 Oct 2021 15:39:05 -0400 Subject: [PATCH 21/21] Revert back --- tests/test_stl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 9f19db2647..186d758b84 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -49,7 +49,7 @@ struct visit_helper { }; template -struct type_caster> : optional_caster> {}; +struct type_caster> : optional_caster> {}; template<> struct type_caster : public void_caster {}; }} // namespace pybind11::detail