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

Literal operator bound oddly #228

Open
zwimer opened this issue Sep 20, 2022 · 2 comments
Open

Literal operator bound oddly #228

zwimer opened this issue Sep 20, 2022 · 2 comments

Comments

@zwimer
Copy link
Contributor

zwimer commented Sep 20, 2022

When binding user-defined literal operators, binder seems to give undesired result.
Consider:

namespace Test {
  struct A { int a; };
  inline A operator"" _a(const char * const c, unsigned long a) { return {0}; }
}

The relevant bit of output is:

M("Test").def("operator""_a", (struct Test::A (*)(const char *const, unsigned long)) &Test::operator""_a, "C++: Test::operator""_a(const char *const, unsigned long) -->  struct Test::A", pybind11::arg("c"), pybind11::arg("a"));

Note that "operator""_a" is a valid string that ends up as "operator_a"; though I suspect this is a bug that happens to fail less loudly than it could have.

@zwimer
Copy link
Contributor Author

zwimer commented Oct 12, 2022

I'm not sure if this should be marked as a bug or not. I imagine it is, but it is one that happens to not break things but rather bind oddly because of C++ syntax rules.

@lyskov
Copy link
Member

lyskov commented Oct 27, 2022

Thank you for letting me know @zwimer ! This is definitely fixable, i am adding this to my list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants