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 {