X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/5224670fe4e903bd507eabd486f8723353893bfa..3efa02fb3a9f0a0566a7f3c99a1efb94e30ea4a6:/rpc/marshall_wrap.h diff --git a/rpc/marshall_wrap.h b/rpc/marshall_wrap.h index 2e54e47..04f5268 100644 --- a/rpc/marshall_wrap.h +++ b/rpc/marshall_wrap.h @@ -17,14 +17,6 @@ typedef std::function handler; // // We implement an 'invoke' function for functions of the RPC handler // signature, i.e. int(R & r, const Args...) -// -// One thing we need in order to accomplish this is a way to cause the compiler -// to specialize 'invoke' with a parameter pack containing a list of indices -// for the elements of the tuple. This will allow us to call the underlying -// function with the exploded contents of the tuple. The empty type -// tuple_indices accomplishes this. It will be passed in to -// 'invoke' as a parameter which will be ignored, but its type will force the -// compiler to specialize 'invoke' appropriately. // This class encapsulates the default response to runtime unmarshalling // failures. The templated wrappers below may optionally use a different @@ -43,7 +35,7 @@ struct VerifyOnFailure { template typename enable_if::value, RV>::type inline -invoke(RV, F f, void *, R & r, args_type & t, tuple_indices) { +invoke(RV, F f, void *, R & r, args_type & t, std::index_sequence) { return f(r, std::get(t)...); } @@ -51,7 +43,7 @@ invoke(RV, F f, void *, R & r, args_type & t, tuple_indices) { template typename enable_if::value, RV>::type inline -invoke(RV, F f, C *c, R & r, args_type & t, tuple_indices) { +invoke(RV, F f, C *c, R & r, args_type & t, std::index_sequence) { return (c->*f)(r, std::get(t)...); } @@ -88,10 +80,8 @@ struct marshalled_func_imp { // Allocate space for the RPC response -- will be passed into the // function as an lvalue reference. R r; - // 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)); + // Perform the invocation. + RV b = invoke(RV(), f, c, r, t, std::index_sequence_for{}); // Marshall the response. m << r; // Make like a tree.