invoke.fail.cpp 920 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // class function<R(ArgTypes...)>
  11. // R operator()(ArgTypes... args) const
  12. #include <functional>
  13. #include <cassert>
  14. // member data pointer: cv qualifiers should transfer from argument to return type
  15. struct A_int_1
  16. {
  17. A_int_1() : data_(5) {}
  18. int data_;
  19. };
  20. void
  21. test_int_1()
  22. {
  23. // member data pointer
  24. {
  25. int A_int_1::*fp = &A_int_1::data_;
  26. A_int_1 a;
  27. std::function<int& (const A_int_1*)> r2(fp);
  28. const A_int_1* ap = &a;
  29. assert(r2(ap) == 6);
  30. r2(ap) = 7;
  31. assert(r2(ap) == 7);
  32. }
  33. }
  34. int main()
  35. {
  36. test_int_1();
  37. }