Compatibility with old compilers.

This commit is contained in:
Ralf W. Grosse-Kunstleve 2022-06-21 16:26:39 -07:00
parent a8144d971d
commit 1bf2577e1f
2 changed files with 6 additions and 4 deletions

View File

@ -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::type_mrc> : 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; });
}

View File

@ -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::type_mrc> : 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; });
}