From d7efc9b8b1c10c52097d140eba359dd617b1138b Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 17 Jan 2021 13:32:50 -0800 Subject: [PATCH] Adding & using PYBIND11_CLASSH_TYPE_CASTERS define. --- include/pybind11/detail/classh_type_casters.h | 18 ++++++++++++++++ tests/test_classh_wip.cpp | 21 +------------------ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/include/pybind11/detail/classh_type_casters.h b/include/pybind11/detail/classh_type_casters.h index a3708ab30..661a9fbfd 100644 --- a/include/pybind11/detail/classh_type_casters.h +++ b/include/pybind11/detail/classh_type_casters.h @@ -374,5 +374,23 @@ struct classh_type_caster> : smart_holder_type_caster_l operator std::unique_ptr() { return this->loaded_as_unique_ptr(); } }; +#define PYBIND11_CLASSH_TYPE_CASTERS(T) \ + namespace pybind11 { \ + namespace detail { \ + template <> \ + class type_caster : public classh_type_caster {}; \ + template <> \ + class type_caster> : public classh_type_caster> {}; \ + template <> \ + class type_caster> \ + : public classh_type_caster> {}; \ + template <> \ + class type_caster> : public classh_type_caster> {}; \ + template <> \ + class type_caster> \ + : public classh_type_caster> {}; \ + } \ + } + } // namespace detail } // namespace pybind11 diff --git a/tests/test_classh_wip.cpp b/tests/test_classh_wip.cpp index 7bf976fca..79821f330 100644 --- a/tests/test_classh_wip.cpp +++ b/tests/test_classh_wip.cpp @@ -49,26 +49,7 @@ std::unique_ptr unique_ptr_roundtrip(std::unique_ptr obj) { return o } // namespace classh_wip } // namespace pybind11_tests -namespace pybind11 { -namespace detail { - -using mpty = pybind11_tests::classh_wip::mpty; - -template <> -class type_caster : public classh_type_caster {}; -template <> -class type_caster> : public classh_type_caster> {}; -template <> -class type_caster> - : public classh_type_caster> {}; -template <> -class type_caster> : public classh_type_caster> {}; -template <> -class type_caster> - : public classh_type_caster> {}; - -} // namespace detail -} // namespace pybind11 +PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_wip::mpty) namespace pybind11_tests { namespace classh_wip {