From 1bf2577e1f2f3296e929001671f369a499813e10 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 21 Jun 2022 16:26:39 -0700 Subject: [PATCH] Compatibility with old compilers. --- tests/test_odr_guard_1.cpp | 5 +++-- tests/test_odr_guard_2.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_odr_guard_1.cpp b/tests/test_odr_guard_1.cpp index e56bbabbf..c76389064 100644 --- a/tests/test_odr_guard_1.cpp +++ b/tests/test_odr_guard_1.cpp @@ -3,7 +3,8 @@ namespace mrc_ns { // minimal real caster struct type_mrc { - int value = -9999; + explicit type_mrc(int v = -9999) : value(v) {} + int value; }; struct minimal_real_caster { @@ -42,6 +43,6 @@ struct type_caster : mrc_ns::minimal_real_caster {}; } // namespace pybind11 TEST_SUBMODULE(odr_guard_1, m) { - m.def("type_mrc_to_python", []() { return mrc_ns::type_mrc{101}; }); + m.def("type_mrc_to_python", []() { return mrc_ns::type_mrc(101); }); m.def("type_mrc_from_python", [](const mrc_ns::type_mrc &obj) { return obj.value + 100; }); } diff --git a/tests/test_odr_guard_2.cpp b/tests/test_odr_guard_2.cpp index f61ce0a10..1200c8e0d 100644 --- a/tests/test_odr_guard_2.cpp +++ b/tests/test_odr_guard_2.cpp @@ -3,7 +3,8 @@ namespace mrc_ns { // minimal real caster struct type_mrc { - int value = -9999; + explicit type_mrc(int v = -9999) : value(v) {} + int value; }; struct minimal_real_caster { @@ -42,6 +43,6 @@ struct type_caster : mrc_ns::minimal_real_caster {}; } // namespace pybind11 TEST_SUBMODULE(odr_guard_2, m) { - m.def("type_mrc_to_python", []() { return mrc_ns::type_mrc{202}; }); + m.def("type_mrc_to_python", []() { return mrc_ns::type_mrc(202); }); m.def("type_mrc_from_python", [](const mrc_ns::type_mrc &obj) { return obj.value + 200; }); }