I have a template class that takes a std::function as parameter.
Within the class I need a member function returning bool.
If the cbFunctionT returns bool, the function should return that. If the cbFunctionT returns anything other (or is void), the function should return false.
Expect that I need to use the std::enable_if for that.
Question is how can I check whether cbFunctionT returns bool. In the code below I used the std::is_same as a placeholder for the one I am looking for.
template<typename cbFunctionT>
class CallBack
{
template<typename T = cbFunctionT
typename std::enable_if_t<std::is_same<T,bool>::value>* = nullptr>
bool funct()
{
return cbFunctionT();
}
template<typename T = cbFunctionT>
bool funct()
{
return false;
}
}
std::function<bool (Args...)>? - Sam Varshavchikbool? Isconst boolacceptable ?bool&? Something that's implicitly or explicitly convertible tobool? - MSaltersstd::functionmember of typecbFunctionT, possibly calledcbFunction? This code looks like it would returnfalseevery time because it tests thatcbFunctionTisboolandbool()isfalse. - parktomatomi