mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-20 01:42:37 +00:00
Add value_and_holder loaded_v_h;
member (set, but currently unused).
This commit is contained in:
parent
2837df178e
commit
fc5678b08b
@ -853,12 +853,35 @@ public:
|
|||||||
src, convert);
|
src, convert);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator type *() { return this->value; }
|
explicit operator type *() {
|
||||||
// static_cast works around compiler error with MSVC 17 and CUDA 10.2
|
if (typeinfo->default_holder) {
|
||||||
// see issue #2180
|
throw std::runtime_error("BAKEIN_WIP: operator type *()");
|
||||||
explicit operator type &() { return *(static_cast<type *>(this->value)); }
|
}
|
||||||
explicit operator std::shared_ptr<type> *() { return std::addressof(shared_ptr_holder); }
|
return this->value;
|
||||||
explicit operator std::shared_ptr<type> &() { return shared_ptr_holder; }
|
}
|
||||||
|
|
||||||
|
explicit operator type &() {
|
||||||
|
if (typeinfo->default_holder) {
|
||||||
|
throw std::runtime_error("BAKEIN_WIP: operator type &()");
|
||||||
|
}
|
||||||
|
// static_cast works around compiler error with MSVC 17 and CUDA 10.2
|
||||||
|
// see issue #2180
|
||||||
|
return *(static_cast<type *>(this->value));
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit operator std::shared_ptr<type> *() {
|
||||||
|
if (typeinfo->default_holder) {
|
||||||
|
throw std::runtime_error("BAKEIN_WIP: operator std::shared_ptr<type> *()");
|
||||||
|
}
|
||||||
|
return std::addressof(shared_ptr_holder);
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit operator std::shared_ptr<type> &() {
|
||||||
|
if (typeinfo->default_holder) {
|
||||||
|
throw std::runtime_error("BAKEIN_WIP: operator std::shared_ptr<type> &()");
|
||||||
|
}
|
||||||
|
return shared_ptr_holder;
|
||||||
|
}
|
||||||
|
|
||||||
static handle
|
static handle
|
||||||
cast(const std::shared_ptr<type> &src, return_value_policy policy, handle parent) {
|
cast(const std::shared_ptr<type> &src, return_value_policy policy, handle parent) {
|
||||||
@ -885,8 +908,9 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool load_value_smart_holder(value_and_holder && /*v_h*/) {
|
bool load_value_smart_holder(value_and_holder &&v_h) {
|
||||||
throw std::runtime_error("BAKEIN_WIP load_value_smart_holder");
|
loaded_v_h = v_h;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool load_value(value_and_holder &&v_h) {
|
bool load_value(value_and_holder &&v_h) {
|
||||||
@ -905,6 +929,9 @@ protected:
|
|||||||
template <typename T = std::shared_ptr<type>,
|
template <typename T = std::shared_ptr<type>,
|
||||||
detail::enable_if_t<std::is_constructible<T, const T &, type *>::value, int> = 0>
|
detail::enable_if_t<std::is_constructible<T, const T &, type *>::value, int> = 0>
|
||||||
bool try_implicit_casts(handle src, bool convert) {
|
bool try_implicit_casts(handle src, bool convert) {
|
||||||
|
if (typeinfo->default_holder) {
|
||||||
|
throw std::runtime_error("BAKEIN_WIP: try_implicit_casts");
|
||||||
|
}
|
||||||
for (auto &cast : typeinfo->implicit_casts) {
|
for (auto &cast : typeinfo->implicit_casts) {
|
||||||
copyable_holder_caster sub_caster(*cast.first);
|
copyable_holder_caster sub_caster(*cast.first);
|
||||||
if (sub_caster.load(src, convert)) {
|
if (sub_caster.load(src, convert)) {
|
||||||
@ -920,6 +947,7 @@ protected:
|
|||||||
static bool try_direct_conversions(handle) { return false; }
|
static bool try_direct_conversions(handle) { return false; }
|
||||||
|
|
||||||
std::shared_ptr<type> shared_ptr_holder;
|
std::shared_ptr<type> shared_ptr_holder;
|
||||||
|
value_and_holder loaded_v_h;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Specialize for the common std::shared_ptr, so users don't need to
|
/// Specialize for the common std::shared_ptr, so users don't need to
|
||||||
|
Loading…
Reference in New Issue
Block a user