-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ralf W. Grosse-Kunstleve
committed
Jan 22, 2024
1 parent
a894a66
commit 36d145c
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <pybind11/smart_holder.h> | ||
|
||
#include "pybind11_tests.h" | ||
|
||
namespace pybind11_tests { | ||
namespace type_caster_addressof { | ||
|
||
struct UnusualOpRefReturnType {}; | ||
|
||
template <int> // Using int as a trick to easily generate a series of types. | ||
struct UnusualOpRef { | ||
UnusualOpRefReturnType operator&() { return UnusualOpRefReturnType(); } | ||
}; | ||
|
||
} // namespace type_caster_addressof | ||
} // namespace pybind11_tests | ||
|
||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::type_caster_addressof::UnusualOpRef<1>) | ||
|
||
namespace pybind11_tests { | ||
namespace type_caster_addressof { | ||
|
||
py::object PassMovable0(UnusualOpRef<0> &&mvbl) { return py::cast(std::move(mvbl)); } | ||
py::object PassMovable1(UnusualOpRef<1> &&mvbl) { return py::cast(std::move(mvbl)); } | ||
|
||
} // namespace type_caster_addressof | ||
} // namespace pybind11_tests | ||
|
||
TEST_SUBMODULE(type_caster_addressof, m) { | ||
using namespace pybind11_tests::type_caster_addressof; | ||
py::class_<UnusualOpRef<0>>(m, "UnusualOpRef0"); | ||
py::classh<UnusualOpRef<1>>(m, "UnusualOpRef1"); | ||
m.def("CallPassMovable0", []() { return PassMovable0(UnusualOpRef<0>()); }); | ||
m.def("CallPassMovable1", []() { return PassMovable1(UnusualOpRef<1>()); }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from pybind11_tests import type_caster_addressof as m | ||
|
||
|
||
def test_merely_that_it_actually_built(): | ||
assert m.CallPassMovable0().__class__.__name__ == "UnusualOpRef0" | ||
assert m.CallPassMovable1().__class__.__name__ == "UnusualOpRef1" |