X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/ebd5aef6dc92accb509b1cc67eaf72159f35cdfa..06282fd37814c4a9d53bca089b048709b368f5b3:/rpc/marshall_wrap.h?ds=sidebyside diff --git a/rpc/marshall_wrap.h b/rpc/marshall_wrap.h index 4ba7a20..6754acc 100644 --- a/rpc/marshall_wrap.h +++ b/rpc/marshall_wrap.h @@ -3,7 +3,7 @@ #include "marshall.h" -typedef function handler; +typedef std::function handler; // // Automatic marshalling wrappers for RPC handlers @@ -43,17 +43,17 @@ struct VerifyOnFailure { // One for function pointers... template -typename enable_if::value, RV>::type inline +typename enable_if::value, RV>::type inline invoke(RV, F f, void *, R & r, args_type & t, tuple_indices) { - return f(r, move(get(t))...); + return f(r, std::get(t)...); } // And one for pointers to member functions... template -typename enable_if::value, RV>::type inline +typename enable_if::value, RV>::type inline invoke(RV, F f, C *c, R & r, args_type & t, tuple_indices) { - return (c->*f)(r, move(get(t))...); + return (c->*f)(r, std::get(t)...); } // The class marshalled_func_imp uses partial template specialization to @@ -73,29 +73,26 @@ template struct marshalled_func_imp { 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::type; // This type definition represents storage for f's unmarshalled // arguments. decay is (most notably) stripping off const // qualifiers. - using ArgsStorage = tuple::type...>; + using ArgsStorage = tuple::type...>; // Allocate a handler (i.e. function) to hold the lambda // which will unmarshall RPCs and call f. return new handler([=](unmarshall && u, marshall & m) -> RV { // Unmarshall each argument with the correct type and store the // result in a tuple. - ArgsStorage t{u._grab::type>()...}; + ArgsStorage t{u._grab::type>()...}; // Verify successful unmarshalling of the entire input stream. if (!u.okdone()) return (RV)ErrorHandler::unmarshall_args_failure(); // 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 : public marshalled_func_imp {}; template -struct marshalled_func> : +struct marshalled_func> : public marshalled_func_imp {}; #endif