mem_fun.pass.cpp 714 B

12345678910111213141516171819202122232425262728293031
  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. // template<Returnable S, ClassType T>
  11. // mem_fun_t<S,T>
  12. // mem_fun(S (T::*f)());
  13. #include <functional>
  14. #include <cassert>
  15. struct A
  16. {
  17. char a1() {return 5;}
  18. short a2(int i) {return short(i+1);}
  19. int a3() const {return 1;}
  20. double a4(unsigned i) const {return i-1;}
  21. };
  22. int main()
  23. {
  24. A a;
  25. assert(std::mem_fun(&A::a1)(&a) == 5);
  26. }