提问人:Samaritain Sim'S 提问时间:12/5/2022 最后编辑:wohlstadSamaritain Sim'S 更新时间:12/5/2022 访问量:44
模板函数参数不完整类型 c++
Template function parameter incomplete type c++
问:
我有一个模板函数,我通过将另一个函数 cb 作为参数传递来实现。
然后,我得到作为参数传递给 cb 函数的参数类型。
template<typename F>
websockets::handle start_subscription (std::string target, std::string payload, F cb) {
using args_tuple = typename boost::callable_traits::args<F>::type;
using received_message_type = typename std::tuple_element<3, args_tuple>::type;
using return_message_type = typename std::tuple_element<4, args_tuple>::type;
using error_type = typename std::tuple_element<5, args_tuple>::type;
received_message_type received_message{};
return_message_type return_message{};
error_type eerror{};
}
websockets::handle websockets::binance_books(std::vector<std::string> pairs, binance_on_book_received_cb cb) {
std::string target = binance_build_target(pairs, "bookTicker");
std::string payload{""};
return start_subscription(std::move(target), std::move(target), std::move(cb));
}
当我尝试实例化两个或之一时,我收到以下错误消息:received_message_type
error_type
错误:不完整的类型“received_message_type”{又名“Izycoinscppapi::exchanges::Binance::WS::book_ticker_t'} 用于 嵌套名称说明符 received_message_type received_message = received_message_type::construct(json);
但是,它有效。return_message_type
这是 cb 函数的格式。我认为这是因为收到的msg和err参数上的命名空间,但我不明白为什么。
using binance_on_book_received_cb = std::function<bool(const char *fl, int ec, std::string errmsg, exchanges::binance::ws::book_ticker_t receivedmsg, fh_price_t returnmsg, exchanges::binance::errors::error_t err)>;
handle binance_books(std::vector<std::string> pairs, binance_on_book_received_cb cb);
答:
0赞
Samaritain Sim'S
12/5/2022
#1
我找到了问题的原因。我没有导入包含 和 定义的 hppreceived_message_type
error_type
评论
received_message_type