#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
// One for function pointers...
template <class F, class R, class RV, class args_type, size_t... Indices>
-typename enable_if<!is_member_function_pointer<F>::value, RV>::type
+typename enable_if<!std::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, std::get<Indices>(t)...);
}
// And one for pointers to member functions...
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
+typename enable_if<std::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, std::get<Indices>(t)...);
}
// The class marshalled_func_imp uses partial template specialization to
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.
- using ArgsStorage = tuple<typename decay<Args>::type...>;
+ using ArgsStorage = tuple<typename std::decay<Args>::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<typename decay<Args>::type>()...};
+ ArgsStorage t{u._grab<typename std::decay<Args>::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.
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