You could use:
#include <utility> // For std::declval<>()
static_assert(
std::is_convertible<decltype(func(std::declval<SomeType>())), bool>::value,
"Predicate's return type must be convertible to bool");
If you only have the type Predicate
or do not want to use func
in the expression:
static_assert(
std::is_convertible<
decltype(std::declval<Predicate&>()(std::declval<SomeType>())),
bool>::value,
"Predicate's return type must be convertible to bool");