Skip to content

Commit 428b9e2

Browse files
committed
Auto-detect RpcFunctionWrapper type using std::function guides (c++17)
1 parent b1b3fe9 commit 428b9e2

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/wrapper.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ using namespace RpcUtils::detail;
99
#ifdef HANDLE_RPC_ERRORS
1010
#include <stdexcept>
1111
#endif
12-
13-
14-
template<typename F>
15-
class RpcFunctionWrapper;
12+
#include <functional>
1613

1714
class IFunctionWrapper {
1815
public:
@@ -21,7 +18,7 @@ class IFunctionWrapper {
2118
};
2219

2320
template<typename R, typename... Args>
24-
class RpcFunctionWrapper<std::function<R(Args...)>>: public IFunctionWrapper {
21+
class RpcFunctionWrapper: public IFunctionWrapper {
2522
public:
2623
RpcFunctionWrapper(std::function<R(Args...)> func) : _func(func) {}
2724

@@ -102,9 +99,8 @@ class RpcFunctionWrapper<std::function<R(Args...)>>: public IFunctionWrapper {
10299

103100

104101
template<typename F>
105-
auto wrap(F&& f) -> RpcFunctionWrapper<typename arx::function_traits<typename std::decay<F>::type>::function_type> {
106-
using Signature = typename arx::function_traits<typename std::decay<F>::type>::function_type;
107-
return RpcFunctionWrapper<Signature>(std::forward<F>(f));
102+
auto wrap(F&& f) {
103+
return RpcFunctionWrapper(std::function(std::forward<F>(f)));
108104
};
109105

110106
#endif

0 commit comments

Comments
 (0)