mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-23 05:35:13 +00:00
Changing PYBIND11_SMART_HOLDER_TYPE_CASTERS to use __VA_ARGS__.
This commit is contained in:
parent
ab590c624b
commit
1c8795a205
@ -773,28 +773,28 @@ struct smart_holder_type_caster<std::unique_ptr<T const, D>>
|
|||||||
|
|
||||||
#ifndef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
|
#ifndef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
|
||||||
|
|
||||||
# define PYBIND11_SMART_HOLDER_TYPE_CASTERS(T) \
|
# define PYBIND11_SMART_HOLDER_TYPE_CASTERS(...) \
|
||||||
namespace pybind11 { \
|
namespace pybind11 { \
|
||||||
namespace detail { \
|
namespace detail { \
|
||||||
template <> \
|
template <> \
|
||||||
class type_caster<T> : public smart_holder_type_caster<T> {}; \
|
class type_caster<__VA_ARGS__> : public smart_holder_type_caster<__VA_ARGS__> {}; \
|
||||||
template <> \
|
template <> \
|
||||||
class type_caster<std::shared_ptr<T>> \
|
class type_caster<std::shared_ptr<__VA_ARGS__>> \
|
||||||
: public smart_holder_type_caster<std::shared_ptr<T>> {}; \
|
: public smart_holder_type_caster<std::shared_ptr<__VA_ARGS__>> {}; \
|
||||||
template <> \
|
template <> \
|
||||||
class type_caster<std::shared_ptr<T const>> \
|
class type_caster<std::shared_ptr<__VA_ARGS__ const>> \
|
||||||
: public smart_holder_type_caster<std::shared_ptr<T const>> {}; \
|
: public smart_holder_type_caster<std::shared_ptr<__VA_ARGS__ const>> {}; \
|
||||||
template <typename D> \
|
template <typename D> \
|
||||||
class type_caster<std::unique_ptr<T, D>> \
|
class type_caster<std::unique_ptr<__VA_ARGS__, D>> \
|
||||||
: public smart_holder_type_caster<std::unique_ptr<T, D>> {}; \
|
: public smart_holder_type_caster<std::unique_ptr<__VA_ARGS__, D>> {}; \
|
||||||
template <typename D> \
|
template <typename D> \
|
||||||
class type_caster<std::unique_ptr<T const, D>> \
|
class type_caster<std::unique_ptr<__VA_ARGS__ const, D>> \
|
||||||
: public smart_holder_type_caster<std::unique_ptr<T const, D>> {}; \
|
: public smart_holder_type_caster<std::unique_ptr<__VA_ARGS__ const, D>> {}; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# define PYBIND11_SMART_HOLDER_TYPE_CASTERS(T)
|
# define PYBIND11_SMART_HOLDER_TYPE_CASTERS(...)
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class type_caster_for_class_ : public smart_holder_type_caster<T> {};
|
class type_caster_for_class_ : public smart_holder_type_caster<T> {};
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
||||||
|
|
||||||
// Supports easier switching between py::class_<U> and py::class_<U, py::smart_holder>:
|
// Supports easier switching between py::class_<T> and py::class_<T, py::smart_holder>:
|
||||||
// users can simply replace the `_` in `class_` with `h` or vice versa.
|
// users can simply replace the `_` in `class_` with `h` or vice versa.
|
||||||
// Note though that the PYBIND11_SMART_HOLDER_TYPE_CASTERS(U) macro also needs to be
|
// Note though that the PYBIND11_SMART_HOLDER_TYPE_CASTERS(T) macro also needs to be
|
||||||
// added (for `classh`) or commented out (for `class_`).
|
// added (for `classh`) or commented out (when falling back to `class_`).
|
||||||
template <typename type_, typename... options>
|
template <typename type_, typename... options>
|
||||||
class classh : public class_<type_, smart_holder, options...> {
|
class classh : public class_<type_, smart_holder, options...> {
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user