diff --git a/include/pybind11/functional.h b/include/pybind11/functional.h index 7a0988ab0..f8bda6483 100644 --- a/include/pybind11/functional.h +++ b/include/pybind11/functional.h @@ -65,12 +65,19 @@ public: } }; - value = [hfunc = func_handle(std::move(func))](Args... args) -> Return { - gil_scoped_acquire acq; - object retval(hfunc.f(std::forward(args)...)); - /* Visual studio 2015 parser issue: need parentheses around this expression */ - return (retval.template cast()); + // to emulate 'move initialization capture' in C++11 + struct func_wrapper { + func_handle hfunc; + func_wrapper(func_handle&& hf): hfunc(std::move(hf)) {} + Return operator()(Args... args) const { + gil_scoped_acquire acq; + object retval(hfunc.f(std::forward(args)...)); + /* Visual studio 2015 parser issue: need parentheses around this expression */ + return (retval.template cast()); + } }; + + value = func_wrapper(func_handle(std::move(func))); return true; }