Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <type_traits>
  2.  
  3. using std::is_callable_v;
  4.  
  5. template <typename Fn, typename A> constexpr auto bind(Fn fn, A &&a) noexcept {
  6. return [fn, a](auto &&... args) { return fn(a, args...); };
  7. }
  8.  
  9. int main() {
  10. constexpr auto b0 = bind([]() {}, 4);
  11. constexpr auto b2 = bind([](int, int) {}, 4);
  12.  
  13. // OK.
  14. static_assert(is_callable_v<decltype(b2)(int)>);
  15.  
  16. // FAILING.
  17. static_assert(!is_callable_v<decltype(b0)()>);
  18. static_assert(!is_callable_v<decltype(b2)()>);
  19. static_assert(!is_callable_v<decltype(b2)(int, int)>);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement