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:
Dean Moldovan
2017-05-09 23:30:05 +02:00
committed by GitHub
parent 77710ff01c
commit 78f1dcf98f
3 changed files with 20 additions and 4 deletions

View File

@@ -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: