Is method overload generally supported?

19 views
Skip to first unread message

Gaël

unread,
Mar 31, 2022, 2:17:59 PM3/31/22
to cython-users
I want to wrap this as part of a C++ class definition:

template <typename T>
  void setParam(const std::string &name, const T &v) const;
  void setParam(const std::string &name, const char *v) const;
  void setParam(const std::string &name, const std::string &v) const;
  void setParam(const std::string &name, EnumType , const void *) const;

which I transformed to

from libcpp cimport string

cdef extern from "headers.h" namespace "deep::namespace":
    cdef cppclass MyObject:
        void setParam[T](const string &name, const T &v) const
        void setParam(const string &name, const char *v) const
        void setParam(const string &name, const string &v) const
        void setParam (const string &name, WrappedEnum dt, const void *v) const

This does not work as intended: the first setParam is always selected whatever happens. I manually cast all my inputs to match the last definition, to no avail. If I want the last definition, I need to rename it or comment out all the other ones. Have I missed something?

Gaël

unread,
Mar 31, 2022, 3:47:49 PM3/31/22
to cython-users
Ahhhh, I found a few bug reports dating from a few years back... It's another instance of the "inherited class are losing it" (subclasses only remember a single instance of overloaded functions)...

Anyway, will rename each of those methods: there aren't many eventually so no big deal.
Reply all
Reply to author
Forward
0 new messages