mem_fun1_t.pass.cpp 808 B

123456789101112131415161718192021222324252627282930313233
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <functional>
  10. // mem_fun1_t
  11. #include <functional>
  12. #include <type_traits>
  13. #include <cassert>
  14. struct A
  15. {
  16. char a1() {return 5;}
  17. short a2(int i) {return short(i+1);}
  18. int a3() const {return 1;}
  19. double a4(unsigned i) const {return i-1;}
  20. };
  21. int main()
  22. {
  23. typedef std::mem_fun1_t<short, A, int> F;
  24. static_assert((std::is_base_of<std::binary_function<A*, int, short>, F>::value), "");
  25. const F f(&A::a2);
  26. A a;
  27. assert(f(&a, 5) == 6);
  28. }