mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-27 08:04:56 +00:00
* git merge --squash purge_internals_versions_4_5
* Remove PYBIND11_HAS_INTERNALS_WITH_SMART_HOLDER_SUPPORT, set PYBIND11_INTERNALS_VERSION 7
* Remove all uses of PYBIND11_SMART_HOLDER_ENABLED under include/pybind11
* Remove obsolete PYBIND11_ACTUALLY_USING_SMART_HOLDER_AS_DEFAULT macro.
* Remove PYBIND11_SMART_HOLDER_ENABLED in ubench/holder_comparison.cpp
* Remove all uses of PYBIND11_SMART_HOLDER_ENABLED under tests/
* Remove `#define PYBIND11_SMART_HOLDER_ENABLED`
* Remove all uses of PYBIND11_SMART_HOLDER_TYPE_CASTERS under tests/
* Remove all uses of PYBIND11_TYPE_CASTER_BASE_HOLDER under tests/
* Add missing `#include <cstdint>`
Example error message (🐍 3.11 • ubuntu-latest • x64, GNU 13.3.0):
```
include/pybind11/detail/value_and_holder.h:56:52: error: ‘uint8_t’ is not a member of ‘std’; did you mean ‘wint_t’?
56 | inst->nonsimple.status[index] &= (std::uint8_t) ~instance::status_holder_constructed;
| ^~~~~~~
```
* Change PYBIND11_INTERNALS_VERSION to 106: It will be changed to 7 in a follow-on PR that actually changes the internals.
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
#include <pybind11/smart_holder.h>
|
|
|
|
#include "pybind11_tests.h"
|
|
|
|
#include <memory>
|
|
|
|
namespace pybind11_tests {
|
|
namespace class_sh_disowning {
|
|
|
|
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 same_twice(std::unique_ptr<Atype<1>> at1a, std::unique_ptr<Atype<1>> at1b) {
|
|
return at1a->get() * 100 + at1b->get() * 10;
|
|
}
|
|
|
|
int mixed(std::unique_ptr<Atype<1>> at1, std::unique_ptr<Atype<2>> at2) {
|
|
return at1->get() * 200 + at2->get() * 20;
|
|
}
|
|
|
|
int overloaded(std::unique_ptr<Atype<1>> at1, int i) { return at1->get() * 30 + i; }
|
|
int overloaded(std::unique_ptr<Atype<2>> at2, int i) { return at2->get() * 40 + i; }
|
|
|
|
} // namespace class_sh_disowning
|
|
} // namespace pybind11_tests
|
|
|
|
TEST_SUBMODULE(class_sh_disowning, m) {
|
|
using namespace pybind11_tests::class_sh_disowning;
|
|
|
|
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);
|
|
|
|
m.def("same_twice", same_twice);
|
|
|
|
m.def("mixed", mixed);
|
|
|
|
m.def("overloaded", (int (*)(std::unique_ptr<Atype<1>>, int)) &overloaded);
|
|
m.def("overloaded", (int (*)(std::unique_ptr<Atype<2>>, int)) &overloaded);
|
|
}
|