2024-07-09 20:34:27 +00:00
|
|
|
#include <pybind11/smart_holder.h>
|
|
|
|
|
2024-06-29 17:55:25 +00:00
|
|
|
#include "pybind11_tests.h"
|
|
|
|
|
2024-06-29 18:09:03 +00:00
|
|
|
namespace pybind11_tests {
|
|
|
|
namespace wip {
|
|
|
|
|
2024-07-09 20:34:27 +00:00
|
|
|
template <int SerNo> // Using int as a trick to easily generate a series of types.
|
|
|
|
struct Atype {
|
|
|
|
int val = 0;
|
|
|
|
explicit Atype(int val_) : val{val_} {}
|
|
|
|
int get() const { return val * 10 + SerNo; }
|
|
|
|
};
|
|
|
|
|
|
|
|
int mixed(std::unique_ptr<Atype<1>> at1, std::unique_ptr<Atype<2>> at2) {
|
|
|
|
return at1->get() * 200 + at2->get() * 20;
|
|
|
|
}
|
2024-06-29 18:09:03 +00:00
|
|
|
|
|
|
|
} // namespace wip
|
|
|
|
} // namespace pybind11_tests
|
|
|
|
|
2024-07-09 20:34:27 +00:00
|
|
|
using namespace pybind11_tests::wip;
|
2024-06-29 18:09:03 +00:00
|
|
|
|
2024-07-09 20:34:27 +00:00
|
|
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(Atype<1>)
|
|
|
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(Atype<2>)
|
2024-06-29 18:09:03 +00:00
|
|
|
|
2024-07-09 20:34:27 +00:00
|
|
|
TEST_SUBMODULE(wip, m) {
|
|
|
|
py::classh<Atype<1>>(m, "Atype1").def(py::init<int>()).def("get", &Atype<1>::get);
|
|
|
|
py::classh<Atype<2>>(m, "Atype2").def(py::init<int>()).def("get", &Atype<2>::get);
|
2024-06-30 21:09:19 +00:00
|
|
|
|
2024-07-09 20:34:27 +00:00
|
|
|
m.def("mixed", mixed);
|
2024-06-29 18:09:03 +00:00
|
|
|
}
|