invoke_int_0.pass.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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<CopyConstructible Fn, CopyConstructible... Types>
  11. // unspecified bind(Fn, Types...);
  12. // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
  13. // unspecified bind(Fn, Types...);
  14. #include <functional>
  15. #include <cassert>
  16. template <class R, class F>
  17. void
  18. test(F f, R expected)
  19. {
  20. assert(f() == expected);
  21. }
  22. template <class R, class F>
  23. void
  24. test_const(const F& f, R expected)
  25. {
  26. assert(f() == expected);
  27. }
  28. int f() {return 1;}
  29. struct A_int_0
  30. {
  31. int operator()() {return 4;}
  32. int operator()() const {return 5;}
  33. };
  34. int main()
  35. {
  36. test(std::bind(f), 1);
  37. test(std::bind(&f), 1);
  38. test(std::bind(A_int_0()), 4);
  39. test_const(std::bind(A_int_0()), 5);
  40. test(std::bind<int>(f), 1);
  41. test(std::bind<int>(&f), 1);
  42. test(std::bind<int>(A_int_0()), 4);
  43. test_const(std::bind<int>(A_int_0()), 5);
  44. }