invoke_int_0.pass.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03
  10. // <functional>
  11. // template<CopyConstructible Fn, CopyConstructible... Types>
  12. // unspecified bind(Fn, Types...);
  13. // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
  14. // unspecified bind(Fn, Types...);
  15. #include <functional>
  16. #include <cassert>
  17. template <class R, class F>
  18. void
  19. test(F f, R expected)
  20. {
  21. assert(f() == expected);
  22. }
  23. template <class R, class F>
  24. void
  25. test_const(const F& f, R expected)
  26. {
  27. assert(f() == expected);
  28. }
  29. int f() {return 1;}
  30. struct A_int_0
  31. {
  32. int operator()() {return 4;}
  33. int operator()() const {return 5;}
  34. };
  35. int main()
  36. {
  37. test(std::bind(f), 1);
  38. test(std::bind(&f), 1);
  39. test(std::bind(A_int_0()), 4);
  40. test_const(std::bind(A_int_0()), 5);
  41. test(std::bind<int>(f), 1);
  42. test(std::bind<int>(&f), 1);
  43. test(std::bind<int>(A_int_0()), 4);
  44. test_const(std::bind<int>(A_int_0()), 5);
  45. }