In a flow I set a templated callback function like below:
otherobju_ptr->Req(std::bind(&A::test<uint16_t>,this,std::placeholders::_1), id);
Now before invoking the callback I need to validate if the callback is of valid signature type:
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 <uint16_t>
static_assert(std::is_convertible_v<decltype(callback), std::function<void(const var&)>>, "Wrong Callback function");
}
};
I am not able to find the solution as is make the signature like below:
static_assert(std::is_convertible_v<decltype(callback), std::function<void<uint16_t>(const bool&)>>, "Wrong Signature!");
It errors out - is there a way we can validate the template arguments type of a std::function callback?
Aucun commentaire:
Enregistrer un commentaire