mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-29 08:32:02 +00:00
Use std::unique_ptr<T>
as default holder again.
This commit is contained in:
parent
58a1b75e43
commit
583c07bffd
@ -1797,8 +1797,14 @@ struct property_cpp_function<
|
||||
|
||||
#endif // PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
|
||||
|
||||
#ifdef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
|
||||
// BAKEIN_WIP: Add comment to explain: This is meant for stress-testing only.
|
||||
template <typename>
|
||||
using default_holder_type = pybindit::memory::smart_holder;
|
||||
#else
|
||||
template <typename T>
|
||||
using default_holder_type = std::unique_ptr<T>;
|
||||
#endif
|
||||
|
||||
template <typename type_, typename... options>
|
||||
class class_ : public detail::generic_type {
|
||||
@ -1816,8 +1822,7 @@ public:
|
||||
using type = type_;
|
||||
using type_alias = detail::exactly_one_t<is_subtype, void, options...>;
|
||||
constexpr static bool has_alias = !std::is_void<type_alias>::value;
|
||||
using holder_type
|
||||
= detail::exactly_one_t<is_holder, pybindit::memory::smart_holder, options...>;
|
||||
using holder_type = detail::exactly_one_t<is_holder, default_holder_type<type>, options...>;
|
||||
|
||||
static_assert(detail::all_of<is_valid_class_option<options>...>::value,
|
||||
"Unknown/invalid class_ template parameters provided");
|
||||
|
@ -13,10 +13,12 @@
|
||||
|
||||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
||||
|
||||
// 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.
|
||||
template <typename type_, typename... options>
|
||||
class classh : public class_<type_, options...> {
|
||||
class classh : public class_<type_, pybindit::memory::smart_holder, options...> {
|
||||
public:
|
||||
using class_<type_, options...>::class_;
|
||||
using class_<type_, pybindit::memory::smart_holder, options...>::class_;
|
||||
};
|
||||
|
||||
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
||||
|
@ -614,8 +614,13 @@ CHECK_NOALIAS(8);
|
||||
CHECK_HOLDER(1, unique);
|
||||
CHECK_HOLDER(2, unique);
|
||||
CHECK_HOLDER(3, unique);
|
||||
#ifdef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
|
||||
CHECK_SMART_HOLDER(4);
|
||||
CHECK_SMART_HOLDER(5);
|
||||
#else
|
||||
CHECK_HOLDER(4, unique);
|
||||
CHECK_HOLDER(5, unique);
|
||||
#endif
|
||||
CHECK_HOLDER(6, shared);
|
||||
CHECK_HOLDER(7, shared);
|
||||
CHECK_HOLDER(8, shared);
|
||||
|
Loading…
Reference in New Issue
Block a user