Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflecting const/non const function overloads #2

Closed
cszawisza opened this issue Sep 10, 2019 · 1 comment
Closed

Reflecting const/non const function overloads #2

cszawisza opened this issue Sep 10, 2019 · 1 comment
Labels
question Further information is requested

Comments

@cszawisza
Copy link

Hi!

I got an class

class X{};

class A{
public:
  X& foo();
  const X& foo() const;
};

And I want to bind it to couple of script languages (chaiscript, python) and I need information about constness of given method for example pybind handles it by adding an additional tag

struct Widget {
    int foo(int x, float y);
    int foo(int x, float y) const;
};

py::class_<Widget>(m, "Widget")
   .def("foo_mutable", py::overload_cast<int, float>(&Widget::foo))
   .def("foo_const",   py::overload_cast<int, float>(&Widget::foo, py::const_));

How to properly reflect those methods using refl-cpp library?

@veselink1
Copy link
Owner

Sorry, but it is not entirely clear to me what the use case is. refl-cpp generally differentiates members by their name only. That is, a member descriptor in refl-cpp is responsible for all overloads of a member function "foo". If you would like to obtain a pointer to a member function, you could use the .pointer member variable of the descriptor. It is only available if .is_resolved is true though, otherwise, you will be required to use the .resolve() member function and provide it with the full type of the function pointer which is required. There currently is no easier way to resolve an overloaded function pointer, but work is being done to resolve this issue.

@veselink1 veselink1 added the question Further information is requested label Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants