Skip to content

Commit

Permalink
Avoid superfluous initialization in type_caster<wrapper_type>
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Jul 3, 2023
1 parent 7cf82f2 commit 8c75c97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/nanobind/nb_cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ struct type_caster<T, enable_if_t<std::is_base_of_v<detail::api_tag, T>>> {
public:
NB_TYPE_CASTER(T, T::Name)

type_caster() : value(nullptr, ::nanobind::detail::steal_t()) { }

bool from_python(handle src, uint8_t, cleanup_list *) noexcept {
if (!isinstance<T>(src))
return false;
Expand Down
2 changes: 2 additions & 0 deletions include/nanobind/nb_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class handle : public detail::api<handle> {
handle(handle &&) noexcept = default;
handle &operator=(const handle &) = default;
handle &operator=(handle &&) noexcept = default;
NB_INLINE handle(std::nullptr_t, detail::steal_t) : m_ptr(nullptr) { }
NB_INLINE handle(std::nullptr_t) : m_ptr(nullptr) { }
NB_INLINE handle(const PyObject *ptr) : m_ptr((PyObject *) ptr) { }
NB_INLINE handle(const PyTypeObject *ptr) : m_ptr((PyObject *) ptr) { }

Expand Down

0 comments on commit 8c75c97

Please sign in to comment.