Skip to content

Commit

Permalink
Fixed issues when RPC_HPP_ENABLE_POINTERS is not defined (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
jharmer95 authored Mar 24, 2021
1 parent 8b539ca commit 46a14dd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
7 changes: 3 additions & 4 deletions include/rpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,15 +1287,14 @@ inline namespace client
template<typename R, typename... Args>
packed_func<R, Args...> pack_call(std::string&& func_name, Args&&... args)
{
std::array<std::any, sizeof...(Args)> argArray{ std::forward<Args>(args)... };

if constexpr (std::is_void_v<R>)
{
return packed_func<void, Args...>(std::move(func_name), argArray);
return packed_func<void, Args...>(std::move(func_name), std::forward_as_tuple(args...));
}
else
{
return packed_func<R, Args...>(std::move(func_name), std::nullopt, argArray);
return packed_func<R, Args...>(
std::move(func_name), std::nullopt, std::forward_as_tuple(args...));
}
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions include/rpc_adapters/rpc_boost_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,17 @@ bjson_val bjson_adapter::from_packed_func(packed_func<R, Args...>&& pack)

ret_j["args"] = bjson::array{};
auto& args = ret_j["args"].as_array();
unsigned i = 0;

const auto& argTup = pack.get_args();

# if defined(RPC_HPP_ENABLE_POINTERS)
i = 0;
unsigned i = 0;

details::for_each_tuple(argTup, [&args, &pack, &i](auto x) {
const auto arg_sz = pack.get_arg_arr_sz(i++);
push_arg(x, args, arg_sz);
});

# else
details::for_each_tuple(argTup, [&args](auto x) { push_arg(x, args, 0); });
# endif
Expand Down
8 changes: 4 additions & 4 deletions include/rpc_adapters/rpc_njson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,17 @@ njson njson_adapter::from_packed_func(packed_func<R, Args...>&& pack)
}

ret_j["args"] = njson::array();
unsigned i = 0;

const auto& argTup = pack.get_args();

# if defined(RPC_HPP_ENABLE_POINTERS)
i = 0;
unsigned i = 0;

details::for_each_tuple(argTup, [&ret_j, &pack, &i](auto x) {
const auto arg_sz = pack.get_arg_arr_sz(i++);
push_arg(x, ret_j["args"], arg_sz);
});

# else
details::for_each_tuple(argTup, [&ret_j](auto x) { push_arg(x, ret_j["args"], 0); });
# endif
Expand Down Expand Up @@ -469,17 +469,17 @@ byte_vec generic_serial_adapter::from_packed_func(packed_func<R, Args...>&& pack
}

ret_j["args"] = njson::array();
unsigned i = 0;

const auto& argTup = pack.get_args();

# if defined(RPC_HPP_ENABLE_POINTERS)
i = 0;
unsigned i = 0;

details::for_each_tuple(argTup, [&ret_j, &pack, &i](auto x) {
const auto arg_sz = pack.get_arg_arr_sz(i++);
push_arg(x, ret_j["args"], arg_sz);
});

# else
details::for_each_tuple(argTup, [&ret_j](auto x) { push_arg(x, ret_j["args"], 0); });
# endif
Expand Down
4 changes: 2 additions & 2 deletions include/rpc_adapters/rpc_rapidjson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,17 @@ rpdjson_doc rpdjson_adapter::from_packed_func(packed_func<R, Args...>&& pack)

rpdjson_val args;
args.SetArray();
unsigned i = 0;

const auto& argTup = pack.get_args();

# if defined(RPC_HPP_ENABLE_POINTERS)
i = 0;
unsigned i = 0;

details::for_each_tuple(argTup, [&args, &alloc, &pack, &i](auto x) {
const auto arg_sz = pack.get_arg_arr_sz(i++);
push_arg(x, args, arg_sz, alloc);
});

# else
details::for_each_tuple(argTup, [&args, &alloc](auto x) { push_arg(x, args, 0, alloc); });
# endif
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_library(catch2_lib STATIC catch2_main.cpp)
add_library(asio_lib INTERFACE)
target_compile_definitions(asio_lib INTERFACE ASIO_STANDALONE)

if(${USE_CONAN})
set(CONAN_EXTRA_REQUIRES "catch2/[>2.10.0 <3.0.0]" "asio/[>=1.14.0]")
Expand Down

0 comments on commit 46a14dd

Please sign in to comment.