binder icon indicating copy to clipboard operation
binder copied to clipboard

Literal operator bound oddly

Open zwimer opened this issue 3 years ago • 2 comments

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 avatar Sep 20 '22 22:09 zwimer

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.

zwimer avatar Oct 12 '22 01:10 zwimer

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

lyskov avatar Oct 27 '22 22:10 lyskov