From 426cbf616c7a4465e707d6f5cd0d11ab9ce27905 Mon Sep 17 00:00:00 2001 From: Chad Austin Date: Mon, 15 Apr 2013 22:26:21 -0700 Subject: Support returning movable types --- system/include/emscripten/wire.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/include/emscripten/wire.h b/system/include/emscripten/wire.h index 0e8334e8..6fb15fc7 100755 --- a/system/include/emscripten/wire.h +++ b/system/include/emscripten/wire.h @@ -205,6 +205,10 @@ namespace emscripten { struct BindingType : public BindingType { }; + template + struct BindingType : public BindingType { + }; + template struct BindingType : public BindingType { }; @@ -236,10 +240,14 @@ namespace emscripten { typedef typename std::remove_reference::type ActualT; typedef ActualT* WireType; - static WireType toWireType(T v) { + static WireType toWireType(const T& v) { return new T(v); } + static WireType toWireType(T&& v) { + return new T(std::forward(v)); + } + static ActualT& fromWireType(WireType p) { return *p; } @@ -282,8 +290,8 @@ namespace emscripten { {}; template - auto toWireType(const T& v) -> typename BindingType::WireType { - return BindingType::toWireType(v); + auto toWireType(T&& v) -> typename BindingType::WireType { + return BindingType::toWireType(std::forward(v)); } template -- cgit v1.2.3-18-g5258