mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Fix char & arguments being non-bindable
This changes the caster to return a reference to a (new) local `CharT` type caster member so that binding lvalue-reference char arguments works (currently it results in a compilation failure). Fixes #1116
This commit is contained in:
@@ -50,7 +50,9 @@ TEST_SUBMODULE(builtin_casters, m) {
|
||||
// test_single_char_arguments
|
||||
m.attr("wchar_size") = py::cast(sizeof(wchar_t));
|
||||
m.def("ord_char", [](char c) -> int { return static_cast<unsigned char>(c); });
|
||||
m.def("ord_char_lv", [](char &c) -> int { return static_cast<unsigned char>(c); });
|
||||
m.def("ord_char16", [](char16_t c) -> uint16_t { return c; });
|
||||
m.def("ord_char16_lv", [](char16_t &c) -> uint16_t { return c; });
|
||||
m.def("ord_char32", [](char32_t c) -> uint32_t { return c; });
|
||||
m.def("ord_wchar", [](wchar_t c) -> int { return c; });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user