diff --git a/include/eigenpy/optional.hpp b/include/eigenpy/optional.hpp index be6fbe4742a6939982641512233ac6a50305b3e5..5daffd5bd55bc14b4ff7241d592bdf5a00e27c00 100644 --- a/include/eigenpy/optional.hpp +++ b/include/eigenpy/optional.hpp @@ -1,4 +1,6 @@ +/// /// Copyright (c) 2023 CNRS INRIA +/// /// Definitions for exposing boost::optional<T> types. /// Also works with std::optional. @@ -7,6 +9,8 @@ #include "eigenpy/fwd.hpp" #include "eigenpy/eigen-from-python.hpp" +#include "eigenpy/registration.hpp" + #include <boost/optional.hpp> #ifdef EIGENPY_WITH_CXX17_SUPPORT #include <optional> @@ -35,6 +39,7 @@ struct expected_pytype_for_arg<std::optional<T> > : expected_pytype_for_arg<T> { } // namespace boost namespace eigenpy { + namespace detail { /// Helper struct to decide which type is the "none" type for a specific @@ -61,7 +66,9 @@ struct NoneToPython { static PyObject *convert(const NoneType &) { Py_RETURN_NONE; } static void registration() { - bp::to_python_converter<NoneType, NoneToPython, false>(); + if (!check_registration<NoneType>()) { + bp::to_python_converter<NoneType, NoneToPython, false>(); + } } }; @@ -81,7 +88,9 @@ struct OptionalToPython { } static void registration() { - bp::to_python_converter<OptionalTpl<T>, OptionalToPython, true>(); + if (!check_registration<OptionalTpl<T> >()) { + bp::to_python_converter<OptionalTpl<T>, OptionalToPython, true>(); + } } }; diff --git a/src/optional.cpp b/src/optional.cpp index eb56912111f9c1b7c0b374b3459e74904025ae88..3edf878ee3f8a55aeb56afb917e9939c5083fbf4 100644 --- a/src/optional.cpp +++ b/src/optional.cpp @@ -1,4 +1,6 @@ +/// /// Copyright 2023 CNRS, INRIA +/// #include "eigenpy/optional.hpp"