trexinc / evil-programmers

Misc. Far plugins and tools by evil programmers
66 stars 26 forks source link

Fixes #49

Closed vladfolts closed 3 years ago

alabuzhev commented 3 years ago

Use class template "translate" instead of overridden non-template function "from" to force the lookup within the template instantiation context (not within the template definition context).

What does it solve / improve? Writing py::translate<decltype(i)>::from(i) everywhere instead of py::from(i) doesn't look impressive.

vladfolts commented 3 years ago

What does it solve / improve?

It solves compilation with VS2019. I guess VS2019 is more strict with following C++ standard, the most relevant topic I found here: https://en.cppreference.com/w/cpp/language/dependent_name (see "Lookup rules"). The compilation issue is also reproducible with the latest clang so this is not some VS2019 quirk.

Alternatively, you can make sure that every from specialization is declared before all its calls (all the specializations are visible from the template definition context). I tried it first and it works but it looks bad since the current design suggests that you are declaring specialized from along with py::object subclasses.

Writing py::translate<decltype(i)>::from(i) everywhere instead of py::from(i) doesn't look impressive.

Yeah, I think it can be mitigated somehow using yet another helper function/class but I did not think much about it since I did not encounter many such cases...

alabuzhev commented 3 years ago

I see. So much for "backwards compatibility" 🤦