From 74d335a53580477bad8b5a1bea2db14b5788ce02 Mon Sep 17 00:00:00 2001 From: Toru Niina Date: Wed, 10 Jul 2019 17:13:56 +0900 Subject: [PATCH] Replace a usage of C++14 language features with C++11 code (#1833) --- include/pybind11/functional.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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; }