mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-12 01:10:34 +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:
@@ -52,7 +52,7 @@ public:
|
||||
auto src = reinterpret_borrow<object>(src_);
|
||||
value = [src](Args... args) -> Return {
|
||||
gil_scoped_acquire acq;
|
||||
object retval(src(std::move(args)...));
|
||||
object retval(src(std::forward<Args>(args)...));
|
||||
/* Visual studio 2015 parser issue: need parentheses around this expression */
|
||||
return (retval.template cast<Return>());
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user