Implement callableCheck() and negatePredicate()
callableCheck(f)
returns a function predicate that for
cheching if f
is callable using a given argument list.
The following allows to check if f can be called with
a and b as arguments. The result is returned as bool_constant
.
auto fCallable = callableCheck(f);
if (fCallable(a,b))
...
negatePredicate(f)
allows to negate a given predicate function.
Similar to the above example checking if f
is not callable
with a and b can be done by:
auto fNotCallable = negatePredicate(callableCheck(f));
if (fNotCallable(a,b))
...
This can be viewed as a runtime/inline version of std::is_detected
and std::negate
. While the latter work on types and require to encode
expressions as meta functions (type-aliases), the functions provided
here work on values and allow to encode expressions in functions. This
has the advantage that is allows to write simple, self-contained scopes
at block-level.
This is based on/incorporates !144 (merged).