Closed
Description
Dear Pybind11 developers,
Looks like both latest master
and stable
seems to produce an error when trying to bind function taking char &
. Could you please looks this up?
Thanks,
#include <pybind11/pybind11.h>
void foo_char(char &) {}
void foo_bool(bool &) {}
void foo_int(int &) {}
void foo_long(long &) {}
void foo_long_long(long long &) {}
void foo_float(float &) {}
void foo_double(double &) {}
PYBIND11_PLUGIN(example) {
pybind11::module m("example", "pybind11 example plugin");
m.def("foo_char", &foo_char);
m.def("foo_bool", &foo_bool);
m.def("foo_int", &foo_int);
m.def("foo_long", &foo_long);
m.def("foo_long_long", &foo_long_long);
m.def("foo_float", &foo_float);
m.def("foo_double", &foo_double);
return m.ptr();
}
Error:
In file included from /home/benchmark/src/pybind11/include/pybind11/pybind11.h:43:
In file included from /home/benchmark/src/pybind11/include/pybind11/attr.h:13:
/home/benchmark/src/pybind11/include/pybind11/cast.h:1858:38: error: non-const lvalue reference to type 'char' cannot bind to a temporary of type 'typename make_caster<char &>::cast_op_type<typename std::add_rvalue_reference<char &>::type>' (aka 'char')
return std::forward<Func>(f)(cast_op<Args>(std::move(std::get<Is>(argcasters)))...);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/benchmark/src/pybind11/include/pybind11/cast.h:1840:35: note: in instantiation of function template specialization 'pybind11::detail::argument_loader<char &>::call_impl<void, void (*&)(char &), 0, pybind11::detail::void_type>' requested here
std::move(*this).template call_impl<Return>(std::forward<Func>(f), indices{}, Guard{});
^
/home/benchmark/src/pybind11/include/pybind11/pybind11.h:154:52: note: in instantiation of function template specialization 'pybind11::detail::argument_loader<char &>::call<void, pybind11::detail::void_type, void (*&)(char &)>' requested here
std::move(args_converter).template call<Return, Guard>(cap->f), policy, call.parent);
^
/home/benchmark/src/pybind11/include/pybind11/pybind11.h:58:9: note: in instantiation of function template specialization 'pybind11::cpp_function::initialize<void (*&)(char &), void, char &, pybind11::name, pybind11::scope, pybind11::sibling>' requested here
initialize(f, f, extra...);
^
/home/benchmark/src/pybind11/include/pybind11/pybind11.h:806:22: note: in instantiation of function template specialization 'pybind11::cpp_function::cpp_function<void, char &, pybind11::name, pybind11::scope, pybind11::sibling>' requested here
cpp_function func(std::forward<Func>(f), name(name_), scope(*this),
^
ret-reference.cpp:14:4: note: in instantiation of function template specialization 'pybind11::module::def<void (*)(char &)>' requested here
m.def("foo_char", &foo_char);
^
1 warning and 1 error generated.
Metadata
Metadata
Assignees
Labels
No labels