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:
Lunderberg
2017-02-22 14:00:59 -05:00
committed by Wenzel Jakob
parent c8e506961c
commit c7fcde7c76
3 changed files with 39 additions and 1 deletions

View File

@@ -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>());
};