mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 14:59:27 +00:00
Fixed compilation error when binding function accepting some forms of std::function (#689)
* Fixed compilation error when defining function accepting some forms of std::function. The compilation error happens only when the functional.h header is present, and the build is done in debug mode, with NDEBUG being undefined. In addition, the std::function must accept an abstract base class by reference. The compilation error occurred in cast.h, when trying to construct a std::tuple<AbstractBase>, rather than a std::tuple<AbstractBase&>. This was caused by functional.h using std::move rather than std::forward, changing the signature of the function being used. This commit contains the fix, along with a test that exhibits the issue when compiled in debug mode without the fix applied. * Moved new std::function tests into test_callbacks, added callback_with_movable test.
This commit is contained in:
@@ -96,3 +96,9 @@ def test_function_signatures(doc):
|
||||
|
||||
assert doc(test_callback3) == "test_callback3(arg0: Callable[[int], int]) -> str"
|
||||
assert doc(test_callback4) == "test_callback4() -> Callable[[int], int]"
|
||||
|
||||
|
||||
def test_movable_object():
|
||||
from pybind11_tests import callback_with_movable
|
||||
|
||||
assert callback_with_movable(lambda _: None) is True
|
||||
|
||||
Reference in New Issue
Block a user