Simplifications and clean-ups
[invirt/third/libt4.git] / rpc / marshall_wrap.h
index 4ba7a20..b895696 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "marshall.h"
 
-typedef function<rpc_protocol::status(unmarshall &&, marshall &)> handler;
+typedef std::function<rpc_protocol::status(unmarshall &&, marshall &)> handler;
 
 //
 // Automatic marshalling wrappers for RPC handlers
@@ -45,7 +45,7 @@ struct VerifyOnFailure {
 template <class F, class R, class RV, class args_type, size_t... Indices>
 typename enable_if<!is_member_function_pointer<F>::value, RV>::type inline 
 invoke(RV, F f, void *, R & r, args_type & t, tuple_indices<Indices...>) {
-    return f(r, move(get<Indices>(t))...);
+    return f(r, get<Indices>(t)...);
 }
 
 // And one for pointers to member functions...
@@ -53,7 +53,7 @@ invoke(RV, F f, void *, R & r, args_type & t, tuple_indices<Indices...>) {
 template <class F, class C, class RV, class R, class args_type, size_t... Indices>
 typename enable_if<is_member_function_pointer<F>::value, RV>::type inline 
 invoke(RV, F f, C *c, R & r, args_type & t, tuple_indices<Indices...>) {
-    return (c->*f)(r, move(get<Indices>(t))...);
+    return (c->*f)(r, get<Indices>(t)...);
 }
 
 // The class marshalled_func_imp uses partial template specialization to
@@ -73,9 +73,6 @@ template <class Functor, class Instance, class Signature,
 template <class F, class C, class ErrorHandler, class R, class RV, class... Args>
 struct marshalled_func_imp<F, C, RV(R &, Args...), ErrorHandler> {
     static inline handler *wrap(F f, C *c=nullptr) {
-        // This type definition corresponds to an empty struct with
-        // template parameters running from 0 up to (# args) - 1.
-        using Indices = typename make_tuple_indices<sizeof...(Args)>::type;
         // This type definition represents storage for f's unmarshalled
         // arguments.  decay is (most notably) stripping off const
         // qualifiers.
@@ -92,10 +89,10 @@ struct marshalled_func_imp<F, C, RV(R &, Args...), ErrorHandler> {
             // Allocate space for the RPC response -- will be passed into the
             // function as an lvalue reference.
             R r;
-            // Perform the invocation.  Note that Indices() calls the default
-            // constructor of the empty struct with the special template
-            // parameters.
-            RV b = invoke(RV(), f, c, r, t, Indices());
+            // Perform the invocation.  Note that TUPLE_INDICES calls the
+            // default constructor of an empty struct with template parameters
+            // running from 0 up to (# args) - 1.
+            RV b = invoke(RV(), f, c, r, t, TUPLE_INDICES(Args));
             // Marshall the response.
             m << r;
             // Make like a tree.
@@ -121,7 +118,7 @@ struct marshalled_func<F, ErrorHandler, RV(C::*)(Args...)> :
     public marshalled_func_imp<F, C, RV(Args...), ErrorHandler> {};
 
 template <class F, class ErrorHandler, class Signature>
-struct marshalled_func<F, ErrorHandler, function<Signature>> :
+struct marshalled_func<F, ErrorHandler, std::function<Signature>> :
     public marshalled_func_imp<F, void, Signature, ErrorHandler> {};
 
 #endif