alloc_rfunction.fail.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <functional>
  9. // XFAIL: c++98, c++03, c++11, c++14
  10. // class function<R(ArgTypes...)>
  11. // template<class A> function(allocator_arg_t, const A&, function&&);
  12. //
  13. // This signature was removed in C++17
  14. #include <functional>
  15. #include <memory>
  16. #include <cassert>
  17. #include "test_macros.h"
  18. class A
  19. {
  20. int data_[10];
  21. public:
  22. static int count;
  23. A()
  24. {
  25. ++count;
  26. for (int i = 0; i < 10; ++i)
  27. data_[i] = i;
  28. }
  29. A(const A&) {++count;}
  30. ~A() {--count;}
  31. int operator()(int i) const
  32. {
  33. for (int j = 0; j < 10; ++j)
  34. i += data_[j];
  35. return i;
  36. }
  37. };
  38. int A::count = 0;
  39. int g(int) { return 0; }
  40. int main(int, char**)
  41. {
  42. {
  43. std::function<int(int)> f = A();
  44. std::function<int(int)> f2(std::allocator_arg, std::allocator<A>(), std::move(f));
  45. }
  46. return 0;
  47. }