В потоке я установил шаблонную функцию обратного вызова, как показано ниже:
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?