Choose function to apply based on the validity of an expression
The problem is the following, in C++14 : Let's have two functions FV&& valid_f , FI&& invalid_f , and arguments Args&&... args The function apply_on_validity should apply valid_f on args if the expression std::forward<FV>(valid_f)(std::forward<Args>(args)...) is valid Otherwise and if std::forward<FV>(invalid_f)(std::forward<Args>(args)...) is a valid expression, apply_on_validity should apply invalid_f on args Otherwise apply_on_validity should do nothing I guess the code should look like something like this: template <class FV, class FI, class... Args, /* Some template metaprog here */> void