| 63 | |
| 64 | template <typename Funct, typename... Args> |
| 65 | bool call_if_valid(Funct&& f, Args&&... args) |
| 66 | /*! |
| 67 | ensures |
| 68 | - if f(std::forward<Args>(args)...) is a valid expression then we evaluate it and return |
| 69 | true. Otherwise we do nothing and return false. |
| 70 | !*/ |
| 71 | { |
| 72 | return switch_(bools(is_invocable<Funct, Args...>{}), |
| 73 | [&](true_t, auto _) { |
| 74 | _(std::forward<Funct>(f))(std::forward<Args>(args)...); |
| 75 | return true; |
| 76 | }, |
| 77 | [](auto...) { |
| 78 | return false; |
| 79 | } |
| 80 | ); |
| 81 | } |
| 82 | |
| 83 | // ---------------------------------------------------------------------------------------- |
| 84 | |