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