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 #ifndef FUNCTION_TYPES_H 11 #define FUNCTION_TYPES_H 12 13 14 class FunctionObject 15 { 16 int data_[10]; // dummy variable to prevent small object optimization in 17 // std::function 18 public: 19 static int count; 20 21 FunctionObject() { 22 ++count; 23 for (int i = 0; i < 10; ++i) data_[i] = i; 24 } 25 26 FunctionObject(const FunctionObject&) {++count;} 27 ~FunctionObject() {--count; ((void)data_); } 28 29 int operator()() const { return 42; } 30 int operator()(int i) const { return i; } 31 int operator()(int i, int) const { return i; } 32 int operator()(int i, int, int) const { return i; } 33 }; 34 35 int FunctionObject::count = 0; 36 37 class MemFunClass 38 { 39 int data_[10]; // dummy variable to prevent small object optimization in 40 // std::function 41 public: 42 static int count; 43 44 MemFunClass() { 45 ++count; 46 for (int i = 0; i < 10; ++i) data_[i] = 0; 47 } 48 49 MemFunClass(const MemFunClass&) {++count; ((void)data_); } 50 51 ~MemFunClass() {--count;} 52 53 int foo() const { return 42; } 54 int foo(int i) const { return i; } 55 int foo(int i, int) const { return i; } 56 int foo(int i, int, int) const { return i; } 57 }; 58 59 int MemFunClass::count = 0; 60 61 int FreeFunction() { return 42; } 62 int FreeFunction(int i) {return i;} 63 int FreeFunction(int i, int) { return i; } 64 int FreeFunction(int i, int, int) { return i; } 65 66 #endif // FUNCTION_TYPES_H 67