alloc_rfunction.fail.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. // <functional>
  10. // XFAIL: c++98, c++03, c++11, c++14
  11. // class function<R(ArgTypes...)>
  12. // template<class A> function(allocator_arg_t, const A&, function&&);
  13. //
  14. // This signature was removed in C++17
  15. #include <functional>
  16. #include <memory>
  17. #include <cassert>
  18. #include "test_macros.h"
  19. class A
  20. {
  21. int data_[10];
  22. public:
  23. static int count;
  24. A()
  25. {
  26. ++count;
  27. for (int i = 0; i < 10; ++i)
  28. data_[i] = i;
  29. }
  30. A(const A&) {++count;}
  31. ~A() {--count;}
  32. int operator()(int i) const
  33. {
  34. for (int j = 0; j < 10; ++j)
  35. i += data_[j];
  36. return i;
  37. }
  38. };
  39. int A::count = 0;
  40. int g(int) { return 0; }
  41. int main()
  42. {
  43. {
  44. std::function<int(int)> f = A();
  45. std::function<int(int)> f2(std::allocator_arg, std::allocator<A>(), std::move(f));
  46. }
  47. }