Skip to content

Commit 7c63d53

Browse files
committed
Auto-detect RpcFunctionWrapper type using std::function guides (c++17)
1 parent 14b7580 commit 7c63d53

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/wrapper.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@ using namespace RpcUtils::detail;
2020
#ifdef HANDLE_RPC_ERRORS
2121
#include <stdexcept>
2222
#endif
23+
#include <functional>
2324

2425
class IFunctionWrapper {
2526
public:
2627
virtual ~IFunctionWrapper() {}
2728
virtual bool operator()(MsgPack::Unpacker& unpacker, MsgPack::Packer& packer) = 0;
2829
};
2930

30-
template<typename F>
31-
class RpcFunctionWrapper;
32-
3331
template<typename R, typename... Args>
34-
class RpcFunctionWrapper<std::function<R(Args...)>>: public IFunctionWrapper {
32+
class RpcFunctionWrapper: public IFunctionWrapper {
3533
public:
3634
RpcFunctionWrapper(std::function<R(Args...)> func) : _func(func) {}
3735

@@ -110,9 +108,9 @@ class RpcFunctionWrapper<std::function<R(Args...)>>: public IFunctionWrapper {
110108
}
111109
};
112110

113-
template<typename F, typename Signature = typename arx::function_traits<typename std::decay<F>::type>::function_type>
114-
auto wrap(F&& f) -> RpcFunctionWrapper<Signature>* {
115-
return new RpcFunctionWrapper<Signature>(std::forward<F>(f));
111+
template<typename F>
112+
auto wrap(F&& f) {
113+
return new RpcFunctionWrapper(std::function(std::forward<F>(f)));
116114
};
117115

118116
#endif

0 commit comments

Comments
 (0)