mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-12 09:17:42 +00:00
Fix std::nullptr_t caster (#840)
* Fix compilation error with std::nullptr_t * Enable conversion from None to std::nullptr_t and std::nullopt_t Fixes #839.
This commit is contained in:
@@ -602,7 +602,11 @@ public:
|
||||
|
||||
template<typename T> struct void_caster {
|
||||
public:
|
||||
bool load(handle, bool) { return false; }
|
||||
bool load(handle src, bool) {
|
||||
if (src && src.is_none())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
static handle cast(T, return_value_policy /* policy */, handle /* parent */) {
|
||||
return none().inc_ref();
|
||||
}
|
||||
@@ -653,7 +657,7 @@ private:
|
||||
void *value = nullptr;
|
||||
};
|
||||
|
||||
template <> class type_caster<std::nullptr_t> : public type_caster<void_type> { };
|
||||
template <> class type_caster<std::nullptr_t> : public void_caster<std::nullptr_t> { };
|
||||
|
||||
template <> class type_caster<bool> {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user