diff options
author | Chad Austin <chad@imvu.com> | 2013-04-16 01:17:56 -0700 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-18 20:08:16 +0300 |
commit | c2bc8d4f1ed4fe5e7477e4dc5d3f32ca5f1e6a56 (patch) | |
tree | f8594eb5de9b05fdac2db5448a35cfa21fb1ee0f /system | |
parent | 426cbf616c7a4465e707d6f5cd0d11ab9ce27905 (diff) |
implement perfect forwarding in embind
Diffstat (limited to 'system')
-rwxr-xr-x | system/include/emscripten/bind.h | 16 | ||||
-rw-r--r-- | system/include/emscripten/val.h | 16 |
2 files changed, 16 insertions, 16 deletions
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index 9b6e69c9..b17488b9 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -723,14 +723,14 @@ namespace emscripten { {} template<typename ReturnType, typename... Args> - ReturnType call(const char* name, Args... args) const { - return Caller<ReturnType, Args...>::call(wrapped, name, args...); + ReturnType call(const char* name, Args&&... args) const { + return Caller<ReturnType, Args...>::call(wrapped, name, std::forward<Args>(args)...); } template<typename ReturnType, typename... Args, typename Default> - ReturnType optional_call(const char* name, Default def, Args... args) const { + ReturnType optional_call(const char* name, Default def, Args&&... args) const { if (has_function(name)) { - return Caller<ReturnType, Args...>::call(wrapped, name, args...); + return Caller<ReturnType, Args...>::call(wrapped, name, std::forward<Args>(args)...); } else { return def(); } @@ -744,15 +744,15 @@ namespace emscripten { // this class only exists because you can't partially specialize function templates template<typename ReturnType, typename... Args> struct Caller { - static ReturnType call(const val& v, const char* name, Args... args) { - return v.call(name, args...).template as<ReturnType>(); + static ReturnType call(const val& v, const char* name, Args&&... args) { + return v.call(name, std::forward<Args>(args)...).template as<ReturnType>(); } }; template<typename... Args> struct Caller<void, Args...> { - static void call(const val& v, const char* name, Args... args) { - v.call_void(name, args...); + static void call(const val& v, const char* name, Args&&... args) { + v.call_void(name, std::forward<Args>(args)...); } }; diff --git a/system/include/emscripten/val.h b/system/include/emscripten/val.h index c27a0fdb..d32c9650 100644 --- a/system/include/emscripten/val.h +++ b/system/include/emscripten/val.h @@ -135,7 +135,7 @@ namespace emscripten { } template<typename... Args> - val new_(Args... args) const { + val new_(Args&&... args) const { using namespace internal; WithPolicies<>::ArgTypeList<Args...> argList; @@ -152,7 +152,7 @@ namespace emscripten { handle, argList.count, argList.types, - toWireType(args)...)); + toWireType(std::forward<Args>(args))...)); } template<typename T> @@ -166,7 +166,7 @@ namespace emscripten { } template<typename... Args> - val operator()(Args... args) { + val operator()(Args&&... args) { using namespace internal; WithPolicies<>::ArgTypeList<Args...> argList; @@ -181,11 +181,11 @@ namespace emscripten { handle, argList.count, argList.types, - toWireType(args)...)); + toWireType(std::forward<Args>(args))...)); } template<typename ...Args> - val call(const char* name, Args... args) const { + val call(const char* name, Args&&... args) const { using namespace internal; WithPolicies<>::ArgTypeList<Args...> argList; @@ -202,11 +202,11 @@ namespace emscripten { name, argList.count, argList.types, - toWireType(args)...)); + toWireType(std::forward<Args>(args))...)); } template<typename ...Args> - void call_void(const char* name, Args... args) const { + void call_void(const char* name, Args&&... args) const { using namespace internal; WithPolicies<>::ArgTypeList<Args...> argList; @@ -222,7 +222,7 @@ namespace emscripten { name, argList.count, argList.types, - toWireType(args)...); + toWireType(std::forward<Args>(args))...); } bool has_function(const char* name) const { |