【发布时间】:2021-04-06 17:51:15
【问题描述】:
我有一个容器来存储包含模板回调的结构。 同时回调签名不包含模板参数。 插入时出现错误:
cannot convert ‘<unresolved overloaded function type>’ to ‘smb1_subdecoder::send_subflow_premature_end_msg_t’ {aka ‘void (smb1_subdecoder::*)(long unsigned int, unsigned char, long unsigned int, unsigned char)’}
note: initializing argument 4 of
‘void smb1_subdecoder::store_subflow_bunch_on_open(
smb1_subdecoder::handle_t, uint64_t, CIFS_RESOURCE_TYPE,
smb1_subdecoder::send_subflow_premature_end_msg_t,
smb1_subdecoder::send_subflow_premature_end_msg_t)’
send_subflow_premature_end_msg_t send_subflow_premature_end_rq_msg,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
插入代码(此处出错):
store_subflow_bunch_on_open(
handle(response_msg.file_id), response_msg.msg_id,
static_cast<CIFS_RESOURCE_TYPE>(parm_open2_rsp->resource_type),
&send_subflow_premature_end_msg<ntdec_cifs_close_request>,
&send_subflow_premature_end_msg<ntdec_cifs_close_response>);
定义:
存储方法:
void smb1_subdecoder::store_subflow_bunch_on_open(
handle_t handle, uint64_t subflow_msg_id, CIFS_RESOURCE_TYPE resource_type,
send_subflow_premature_end_msg_t send_subflow_premature_end_rq_msg,
send_subflow_premature_end_msg_t send_subflow_premature_end_rsp_msg) { ... }
send_subflow_premature_end_msg_t:
typedef void (smb1_subdecoder::*send_subflow_premature_end_msg_t)
(uint64_t, uint8_t, uint64_t, uint8_t);
发送过早结束消息的模板函数(签名不依赖于上述模板参数):
template<class NTDEC_END_OBJECT_T>
void smb1_subdecoder::send_subflow_premature_end_msg(uint64_t subflow_msg_id, uint8_t close_reason,
uint64_t header_msg_id, uint8_t side)
{
NTDEC_END_OBJECT_T end_msg;
_d_smb->proto_fill(end_msg, subflow_msg_id);
end_msg.header_msg_id = header_msg_id;
if (_d_smb->transport() == decoder_smb::TRANSPORT::NETBIOS)
{
const auto* netbios_msg = _d_smb->get_proto_parent<ntdec_object>();
if (netbios_msg)
set_parent_msg_id(end_msg, netbios_msg->msg_id);
}
end_msg.side = (side == -1) ? _d_smb->get_last_data_side() : side;
_d_smb->stream().send_message(end_msg);
}
【问题讨论】: