如何检查模板参数化的回调函数签名是一种

时间:2019-01-09 08:08:59

标签: c++ c++11

在流程中,我设置了一个模板化的回调函数,如下所示:

otherobju_ptr->Req(std::bind(&A::test<uint16_t>,this,std::placeholders::_1), id);

现在在调用回调之前,我需要验证回调是否具有有效的签名类型:

class otherobj  
{
public:
    using CallbackType = std::function<void(const bool&)>;
    int Reg( CallbackType callback, uint32_t& id)
    {
         //Need to check if the function template parameter is correct
          // Trying the below way but not sure where we can give the template parameter <bool>
           static_assert(std::is_convertible_v<decltype(callback), std::function<void(const bool&)>>, "Wrong Callback function");
    }
};  

我无法找到解决方案,如下所示进行签名:

 static_assert(std::is_convertible_v<decltype(callback), std::function<void<bool>(const bool&)>>, "Wrong Signature!"); 

出现错误-有没有一种方法可以验证std :: function回调的模板参数类型?

0 个答案:

没有答案
相关问题