mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-21 20:55:11 +00:00
style: pre-commit fixes
This commit is contained in:
parent
d6df11602b
commit
5afd2c89db
@ -82,14 +82,14 @@ struct base {
|
||||
.. note:: This is an advanced feature. If you use this, you likely need
|
||||
to implement polymorphic_type_hook for your type hierarchy.
|
||||
\endrst */
|
||||
template <typename T> struct custom_base {
|
||||
using caster = void *(*)(void *);
|
||||
template <typename T>
|
||||
struct custom_base {
|
||||
using caster = void *(*) (void *);
|
||||
|
||||
explicit custom_base(const caster &f) : fn(f) {}
|
||||
caster fn;
|
||||
};
|
||||
|
||||
|
||||
/// Keep patient alive while nurse lives
|
||||
template <size_t Nurse, size_t Patient>
|
||||
struct keep_alive {};
|
||||
@ -579,8 +579,7 @@ struct process_attribute<base<T>> : process_attribute_default<base<T>> {
|
||||
/// Process a custom base attribute
|
||||
template <typename T>
|
||||
struct process_attribute<custom_base<T>> : process_attribute_default<custom_base<T>> {
|
||||
static void init(const custom_base<T> &b, type_record *r)
|
||||
{
|
||||
static void init(const custom_base<T> &b, type_record *r) {
|
||||
r->add_base(typeid(T), b.fn);
|
||||
// TODO: rename this to 'nonsimple'?
|
||||
r->multiple_inheritance = true;
|
||||
|
@ -28,7 +28,8 @@ TEST_SUBMODULE(custom_base, m) {
|
||||
|
||||
py::class_<Derived>(m, "Derived", py::custom_base<Base>([](void *o) -> void * {
|
||||
return &reinterpret_cast<Derived *>(o)->base;
|
||||
})).def_readwrite("j", &Derived::j);
|
||||
}))
|
||||
.def_readwrite("j", &Derived::j);
|
||||
|
||||
m.def("create_derived", []() { return new Derived; });
|
||||
m.def("create_base", []() { return new Base; });
|
||||
@ -36,4 +37,4 @@ TEST_SUBMODULE(custom_base, m) {
|
||||
m.def("base_i", [](Base *b) { return b->i; });
|
||||
|
||||
m.def("derived_j", [](Derived *d) { return d->j; });
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user