Interleaving smart_holder_type_casters.h into cast.h.

parent 1c822758
...@@ -2475,6 +2475,28 @@ inline function get_overload(const T *this_ptr, const char *name) { ...@@ -2475,6 +2475,28 @@ inline function get_overload(const T *this_ptr, const char *name) {
#define PYBIND11_OVERLOAD_PURE(ret_type, cname, fn, ...) \ #define PYBIND11_OVERLOAD_PURE(ret_type, cname, fn, ...) \
PYBIND11_OVERRIDE_PURE(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), fn, __VA_ARGS__); PYBIND11_OVERRIDE_PURE(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), fn, __VA_ARGS__);
//SMART_HOLDER_H///////////////////////////////////////////////////////////////////////////////////
// Supports easier switching between py::class_<U> and py::class_<U, py::smart_holder>:
// 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
// added (for `classh`) or commented out (for `class_`).
template <typename type_, typename... options>
class classh : public class_<type_, smart_holder, options...> {
public:
using class_<type_, smart_holder, options...>::class_;
};
// Similar in idea to `py::classh`, but for `std::unique_ptr<U>` holder, to support
// an easier transition to `py::smart_holder` as default holder.
template <typename type_, typename... options>
class classu : public class_<type_, std::unique_ptr<type_>, options...> {
public:
using class_<type_, std::unique_ptr<type_>, options...>::class_;
};
//SMART_HOLDER_H///////////////////////////////////////////////////////////////////////////////////
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) #if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
......
...@@ -4,27 +4,4 @@ ...@@ -4,27 +4,4 @@
#pragma once #pragma once
#include "detail/smart_holder_type_casters.h"
#include "pybind11.h" #include "pybind11.h"
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
// Supports easier switching between py::class_<U> and py::class_<U, py::smart_holder>:
// 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
// added (for `classh`) or commented out (for `class_`).
template <typename type_, typename... options>
class classh : public class_<type_, smart_holder, options...> {
public:
using class_<type_, smart_holder, options...>::class_;
};
// Similar in idea to `py::classh`, but for `std::unique_ptr<U>` holder, to support
// an easier transition to `py::smart_holder` as default holder.
template <typename type_, typename... options>
class classu : public class_<type_, std::unique_ptr<type_>, options...> {
public:
using class_<type_, std::unique_ptr<type_>, options...>::class_;
};
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment