mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 16:13:53 +00:00
Adding & using PYBIND11_CLASSH_TYPE_CASTERS define.
This commit is contained in:
parent
1ef19a1e04
commit
d7efc9b8b1
@ -374,5 +374,23 @@ struct classh_type_caster<std::unique_ptr<T const>> : smart_holder_type_caster_l
|
||||
operator std::unique_ptr<T const>() { return this->loaded_as_unique_ptr(); }
|
||||
};
|
||||
|
||||
#define PYBIND11_CLASSH_TYPE_CASTERS(T) \
|
||||
namespace pybind11 { \
|
||||
namespace detail { \
|
||||
template <> \
|
||||
class type_caster<T> : public classh_type_caster<T> {}; \
|
||||
template <> \
|
||||
class type_caster<std::shared_ptr<T>> : public classh_type_caster<std::shared_ptr<T>> {}; \
|
||||
template <> \
|
||||
class type_caster<std::shared_ptr<T const>> \
|
||||
: public classh_type_caster<std::shared_ptr<T const>> {}; \
|
||||
template <> \
|
||||
class type_caster<std::unique_ptr<T>> : public classh_type_caster<std::unique_ptr<T>> {}; \
|
||||
template <> \
|
||||
class type_caster<std::unique_ptr<T const>> \
|
||||
: public classh_type_caster<std::unique_ptr<T const>> {}; \
|
||||
} \
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pybind11
|
||||
|
@ -49,26 +49,7 @@ std::unique_ptr<mpty> unique_ptr_roundtrip(std::unique_ptr<mpty> obj) { return o
|
||||
} // namespace classh_wip
|
||||
} // namespace pybind11_tests
|
||||
|
||||
namespace pybind11 {
|
||||
namespace detail {
|
||||
|
||||
using mpty = pybind11_tests::classh_wip::mpty;
|
||||
|
||||
template <>
|
||||
class type_caster<mpty> : public classh_type_caster<mpty> {};
|
||||
template <>
|
||||
class type_caster<std::shared_ptr<mpty>> : public classh_type_caster<std::shared_ptr<mpty>> {};
|
||||
template <>
|
||||
class type_caster<std::shared_ptr<mpty const>>
|
||||
: public classh_type_caster<std::shared_ptr<mpty const>> {};
|
||||
template <>
|
||||
class type_caster<std::unique_ptr<mpty>> : public classh_type_caster<std::unique_ptr<mpty>> {};
|
||||
template <>
|
||||
class type_caster<std::unique_ptr<mpty const>>
|
||||
: public classh_type_caster<std::unique_ptr<mpty const>> {};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace pybind11
|
||||
PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_wip::mpty)
|
||||
|
||||
namespace pybind11_tests {
|
||||
namespace classh_wip {
|
||||
|
Loading…
Reference in New Issue
Block a user