Код: Выделить всё
class C
{
public:
template
std::shared_ptr foo();
std::shared_ptr foo(std::string_view sw);
};
class DerivedFromC : public C
{
// no logic concerning foo
};
// in my bindings
pybind11::class_(m, "Name")
.def("foo", pybind11::overload_cast(&DerivedFromC::foo));
Код: Выделить всё
[build] pythonbind.hpp(51,21): error: no matching function for call to object of type 'const detail::overload_cast_impl'
[build] 51 | .def("foo", pybind11::overload_cast(&DerivedFromC::foo));
[build] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] ...\build\vcpkg_installed\x64-windows\include\pybind11/detail/common.h(1106,20): note: candidate template ignored: couldn't infer template argument 'Return'
[build] 1106 | constexpr auto operator()(Return (*pf)(Args...)) const noexcept -> decltype(pf) {
[build] | ^
[build] ...\build\vcpkg_installed\x64-windows\include\pybind11/detail/common.h(1111,20): note: candidate template ignored: couldn't infer template argument 'Return'
[build] 1111 | constexpr auto operator()(Return (Class::*pmf)(Args...), std::false_type = {}) const noexcept
[build] | ^
[build] ...\build\vcpkg_installed\x64-windows\include\pybind11/detail/common.h(1117,20): note: candidate function template not viable: requires 2 arguments, but 1 was provided
[build] 1117 | constexpr auto operator()(Return (Class::*pmf)(Args...) const, std::true_type) const noexcept
[build] | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Подробнее здесь: https://stackoverflow.com/questions/790 ... the-pointe