Bar( Foo& foo ) { foo.registerCallback( this, std::bind( &Bar::callback, this, placeholders::_1, placeholders::_2 ), 444 ); }
TEST(OwnedTest, Release) { Foo* foo = new Foo(); foo->set(42); Owned<Foo> owned(foo); EXPECT_EQ(42, owned->get()); EXPECT_EQ(42, (*owned).get()); EXPECT_EQ(42, owned.get()->get()); Foo* raw = owned.release(); EXPECT_EQ(nullptr, owned.get()); EXPECT_EQ(42, raw->get()); delete raw; EXPECT_EQ(nullptr, owned.get()); }
int main(int argc, char *argv[]) { int n = 0; if(argc > 1) { n = atoi(argv[1]); } int ret = foo(3); try { bar(n); } catch(const char *msg) { fprintf(stderr, "%s.\n", msg); } Foo foo; foo.loop(n); printf("%d.\n", ret); return 0; }
int main() { class Bar { public: Foo a; void test() { a.setX(10); } }; Foo a = test(); TT c = a; Bar b; b.test(); typedef Bar toto_t; return a.getX(); }
void Noninline_Member_Call_Test::run (void) { this->start_timing (); for (u_int i = 0; i < iterations; ++i) foo.func (); this->stop_timing (); }
TEST_F(HazptrTest, basic_refcount) { constructed.store(0); destroyed.store(0); Foo* p = nullptr; int num = 20; for (int i = 0; i < num; ++i) { p = new Foo(i, p); if (i & 1) { p->acquire_ref_safe(); } else { p->acquire_ref(); } } hazptr_holder hptr; hptr.reset(p); for (auto q = p->next_; q; q = q->next_) { q->retire(); } int v = num; for (auto q = p; q; q = q->next_) { CHECK_GT(v, 0); --v; CHECK_EQ(q->val_, v); } CHECK(!p->release_ref()); CHECK_EQ(constructed.load(), num); CHECK_EQ(destroyed.load(), 0); p->retire(); CHECK_EQ(constructed.load(), num); CHECK_EQ(destroyed.load(), 0); hptr.reset(); /* retire enough objects to guarantee reclamation of Foo objects */ for (int i = 0; i < 100; ++i) { auto a = new Dummy; a->retire(); } CHECK_EQ(constructed.load(), num); CHECK_EQ(destroyed.load(), num); }
int func() { Bar *bar1, bar2; Foo foo; int x = x - 0; // should not warn static int y = y / 1; // should not warn float *f; Bar bar_array[5]; *f = *f / 1; // should not warn bar1->b_ = bar1->b_ * 1; // should not warn bar2.c_ = bar2.c_ - 0; // should not warn foo.setA(5); bar_array[3].c_ = bar_array[3].c_ * 1; // should not warn bar_array[x+g].b_ = bar_array[x+g].b_ / 1; // should not warn x += 0; y -= 0; foo = foo; foo.operator=(foo); // should not warn }
TEST_F(HazptrTest, Local) { struct Foo : hazptr_obj_base<Foo> { int a; }; for (int i = 0; i < 100; ++i) { Foo* x = new Foo; x->a = i; hazptr_local<10> hptr; // Protect object hptr[9].reset(x); // Retire object x->retire(); // Unprotect object - hptr2 is nonempty hptr[9].reset(); } { // Abnormal case hazptr_local<HAZPTR_TC_SIZE + 1> h; } }
int l_Foo_add(lua_State * L) { Foo * foo = l_CheckFoo(L, 1); int a = (int)luaL_checknumber(L, 2); int b = (int)luaL_checknumber(L, 3); std::string s = foo->Add(a, b); lua_pushstring(L, s.c_str()); // The Lua stack at this point looks like this: // // 4| result string |-1 // 3| metatable "luaL_foo" |-2 // 2| userdata |-3 // 1| string parameter |-4 // // Return 1 to return the result string to Lua callsite. return 1; }
int main(int argc, char* argv[]) { { Foo a(9); Foo b = a; // same as Foo b(a); Foo c(5); std::cout << a.toString() << std::endl; std::cout << b.toString() << std::endl; std::cout << c.toString() << std::endl; c = a; std::cout << c.toString() << std::endl; c = c; std::cout << c.toString() << std::endl; std::cout << "Swap test ------------------" << std::endl; b.setX(10); std::cout << a.toString() << " " << b.toString() << std::endl; a.swap(b); std::cout << a.toString() << " " << b.toString() << std::endl; } // scoped to print end of main AFTER objects get destructed std::cout << "::main()" << std::endl; return 0; }
// Test app int main( /* int argc, char* argv[] */ ) { ossimInit::instance()->initialize(); Foo* f = new Foo; cout << "count(1): " << f->getRefPtr()->referenceCount() << endl; ossimRefPtr<Obj> refPtr2 = f->getRefPtr(); cout << "count(2): " << f->getRefPtr()->referenceCount() << endl; delete f; f = 0; cout << "count(1): " << refPtr2->referenceCount() << endl; refPtr2 = 0; // Should destroy here... return 0; }
TEST(StrongPointer, move) { bool isDeleted; Foo* foo = new Foo(&isDeleted); ASSERT_EQ(0, foo->getStrongCount()); ASSERT_FALSE(isDeleted) << "Already deleted...?"; sp<Foo> sp1(foo); ASSERT_EQ(1, foo->getStrongCount()); { sp<Foo> sp2 = std::move(sp1); ASSERT_EQ(1, foo->getStrongCount()) << "std::move failed, incremented refcnt"; ASSERT_EQ(nullptr, sp1.get()) << "std::move failed, sp1 is still valid"; // The strong count isn't increasing, let's double check the old object // is properly reset and doesn't early delete sp1 = std::move(sp2); } ASSERT_FALSE(isDeleted) << "deleted too early! still has a reference!"; { // Now let's double check it deletes on time sp<Foo> sp2 = std::move(sp1); } ASSERT_TRUE(isDeleted) << "foo was leaked!"; }
int main() { QSet<QString *> s; qDeleteAll(s); qDeleteAll(s.begin(), s.end()); qDeleteAll(s.values()); // warning QHash<int, QString *> h; qDeleteAll(h); qDeleteAll(h.begin(), h.end()); qDeleteAll(h.values()); // warning QMap<int*, QString *> m; qDeleteAll(m); qDeleteAll(m.begin(), m.end()); qDeleteAll(m.values()); // warning QMultiHash<int, QString *> mh; qDeleteAll(mh); qDeleteAll(mh.begin(), mh.end()); qDeleteAll(mh.values()); // warning QMultiMap<int, QString *> mm; qDeleteAll(mm); qDeleteAll(mm.begin(), mm.end()); qDeleteAll(mm.values()); // warning qDeleteAll(values()); // ok Foo foo; qDeleteAll(foo.values()); // ok qDeleteAll(foo.doSomethingWithValues(h.values())); // ok qDeleteAll(m.keys()); // warning qDeleteAll(keys()); // ok qDeleteAll(h.values(1)); // warning }
int main(){ Foo foo; int x; char c; foo.get(x); foo.get(c); cout << x << endl; cout << c << endl; foo.set('x'); foo.get(x); foo.get(c); cout << x << endl; cout << c << endl; return 0; }
int main() { // Bar { Bar b(8); DisplayMemberVisitor vis; apply_fusion_visitor(vis, b); std::cout << "\n" << vis.complete() << "\n"; Bar cloned; ReadMemberVisitor rv(vis.complete()); apply_read_fusion_visitor(rv, cloned); } std::cout << "\n-----------\n"; // Foo Foo const f{78}; std::string f_serialized; { DisplayMemberVisitor vis; apply_fusion_visitor(vis, f); f_serialized = vis.complete(); std::cout << "\n" << f_serialized << "\n"; } std::cout << "\n-----------\n"; Foo cloned{0}; ReadMemberVisitor rv(f_serialized); apply_read_fusion_visitor(rv, cloned); std::cout << "\n-----------\n"; std::cout << f.get_bar_value().get_integer_value() << " == " << cloned.get_bar_value().get_integer_value() << "\n"; }
int main( void ) { Foo<double, double> a; Foo<double, float > b; Foo<float , double> c; Foo<int , int > d; a.print(); //==> this is T1 T2 structure. b.print(); //==> this is T1 float structure. c.print(); //==> this is float T2 structure. d.print(); //==> this is int int structure. func( 1.0 , 2.0 ); //==> this is T1 T2 function. func( 1.0 , 2.0f ); //==> this is T1 float function. func( 1.0f, 2.0 ); //==> this is float T2 function. func( 1 , 2 ); //==> this is int int function. return 0; }
class Foo { public: void f() { std::cout << "Foo::f()" << std::endl; } virtual void g() { std::cout << "Foo::g()" << std::endl; } } class Bar : public Foo { public: void f() { std::cout << "Bar::f()" << std::endl; } virtual void g() { std::cout << "Bar::g()" << std::endl; } } int main() { Foo foo; Bar bar; Foo *baz = &bar; Bar *quux = &bar; foo.f(); // "Foo::f()" foo.g(); // "Foo::g()" bar.f(); // "Bar::f()" bar.g(); // "Bar::g()" // So far everything we would expect... baz->f(); // "Foo::f()" baz->g(); // "Bar::g()" quux->f(); // "Bar::f()" quux->g(); // "Bar::g()" return 0; }
int func() { Bar *bar1, bar2; Foo local_foo; int x = x; // { dg-bogus "assigned to itself" } static int y = y; // { dg-bogus "assigned to itself" } float *f; Bar bar_array[5]; char n; int overflow; *f = *f; // { dg-bogus "assigned to itself" } bar1->b_ = bar1->b_; // { dg-bogus "assigned to itself" } bar2.c_ = bar2.c_; // { dg-bogus "assigned to itself" } local_foo = local_foo; // { dg-bogus "assigned to itself" } foo = foo; // { dg-bogus "assigned to itself" } foo.setA(5); bar_array[3].c_ = bar_array[3].c_; // { dg-bogus "assigned to itself" } bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-bogus "self-assignment detected" } y = x; x = y; }
int main () { int i = 5; int * a = &i; Foo<int, &i> f; Foo<int, a> g; Foo<int, &j> h; cout << &i << " " << f.bar() << " " << g.bar() << " " << &j << " " << h.bar() << " " << j << " " << *(h.bar()) << " " << endl; // sample output: // yuanc@casqa1:~/testbed/C 1044> ./template // ffbef488 ffbef418 22028 22018 22018 6 6 // only works for the variable of namespace scope return 0; }
void someSub(Foo foo) { foo.print(); }
int main() { Foo foo; foo.bar(); }
void f() { const int N = 10; const int M = 15; Val Arr[N]; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { int k = Arr[i].x + Arr[j].x; // The repeat is there to allow FileCheck to make sure the two variable // names aren't the same. int l = Arr[i].x + Arr[j].x; } } // CHECK-MESSAGES: :[[@LINE-8]]:3: warning: use range-based for loop instead // CHECK-MESSAGES: :[[@LINE-8]]:5: warning: use range-based for loop instead // CHECK-FIXES: for (auto & elem : Arr) // CHECK-FIXES-NEXT: for (auto & Arr_j : Arr) // CHECK-FIXES-NEXT: int k = elem.x + Arr_j.x; // CHECK-FIXES-NOT: int l = elem.x + elem.x; // The inner loop is also convertible, but doesn't need to be converted // immediately. FIXME: update this test when that changes. Val Nest[N][M]; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { printf("Got item %d", Nest[i][j].x); } } // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto & elem : Nest) // CHECK-FIXES-NEXT: for (int j = 0; j < M; ++j) // CHECK-FIXES-NEXT: printf("Got item %d", elem[j].x); // Note that the order of M and N are switched for this test. for (int j = 0; j < M; ++j) { for (int i = 0; i < N; ++i) { printf("Got item %d", Nest[i][j].x); } } // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop instead // CHECK-FIXES-NOT: for (auto & {{[a-zA-Z_]+}} : Nest[i]) // CHECK-FIXES: for (int j = 0; j < M; ++j) // CHECK-FIXES-NEXT: for (auto & elem : Nest) // CHECK-FIXES-NEXT: printf("Got item %d", elem[j].x); // The inner loop is also convertible. Nested<T> NestT; for (Nested<T>::iterator I = NestT.begin(), E = NestT.end(); I != E; ++I) { for (T::iterator TI = (*I).begin(), TE = (*I).end(); TI != TE; ++TI) { printf("%d", *TI); } } // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto & elem : NestT) // CHECK-FIXES-NEXT: for (T::iterator TI = (elem).begin(), TE = (elem).end(); TI != TE; ++TI) // CHECK-FIXES-NEXT: printf("%d", *TI); // The inner loop is also convertible. Nested<S> NestS; for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { for (S::const_iterator SI = (*I).begin(), SE = (*I).end(); SI != SE; ++SI) { printf("%d", *SI); } } // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (const auto & elem : NestS) // CHECK-FIXES-NEXT: for (S::const_iterator SI = (elem).begin(), SE = (elem).end(); SI != SE; ++SI) // CHECK-FIXES-NEXT: printf("%d", *SI); for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { const S &s = *I; for (S::const_iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) { printf("%d", *SI); const_g(SI); } } // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (const auto & s : NestS) for (Nested<S>::iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { S &s = *I; for (S::iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) { printf("%d", *SI); g(SI); } } // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto & s : NestS) Foo foo; for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { const S &s = *I; for (S::const_iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) { printf("%d", *SI); foo.const_g(SI); } } // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (const auto & s : NestS) for (Nested<S>::iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { S &s = *I; for (S::iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) { printf("%d", *SI); foo.g(SI); } } // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto & s : NestS) }
int main() { Foo<double> foo = Foo<double>(); foo.bar(); return 0; }
void hi(Foo & f) { std::cout << "copy "; f.bar(); }
void f() { const int N = 10; const int M = 15; Val Arr[N]; for (int I = 0; I < N; ++I) { for (int J = 0; J < N; ++J) { int K = Arr[I].X + Arr[J].X; // The repeat is there to allow FileCheck to make sure the two variable // names aren't the same. int L = Arr[I].X + Arr[J].X; } } // CHECK-MESSAGES: :[[@LINE-8]]:3: warning: use range-based for loop instead // CHECK-MESSAGES: :[[@LINE-8]]:5: warning: use range-based for loop instead // CHECK-FIXES: for (auto & I : Arr) // CHECK-FIXES-NEXT: for (auto & J : Arr) // CHECK-FIXES-NEXT: int K = I.X + J.X; // CHECK-FIXES-NOT: int L = I.X + I.X; // The inner loop is also convertible, but doesn't need to be converted // immediately. FIXME: update this test when that changes. Val Nest[N][M]; for (int I = 0; I < N; ++I) { for (int J = 0; J < M; ++J) { printf("Got item %d", Nest[I][J].X); } } // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto & I : Nest) // CHECK-FIXES-NEXT: for (int J = 0; J < M; ++J) // CHECK-FIXES-NEXT: printf("Got item %d", I[J].X); // Note that the order of M and N are switched for this test. for (int J = 0; J < M; ++J) { for (int I = 0; I < N; ++I) { printf("Got item %d", Nest[I][J].X); } } // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop instead // CHECK-FIXES-NOT: for (auto & {{[a-zA-Z_]+}} : Nest[I]) // CHECK-FIXES: for (int J = 0; J < M; ++J) // CHECK-FIXES-NEXT: for (auto & I : Nest) // CHECK-FIXES-NEXT: printf("Got item %d", I[J].X); // The inner loop is also convertible. Nested<T> NestT; for (Nested<T>::iterator I = NestT.begin(), E = NestT.end(); I != E; ++I) { for (T::iterator TI = (*I).begin(), TE = (*I).end(); TI != TE; ++TI) { printf("%d", *TI); } } // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto & I : NestT) // CHECK-FIXES-NEXT: for (T::iterator TI = I.begin(), TE = I.end(); TI != TE; ++TI) // CHECK-FIXES-NEXT: printf("%d", *TI); // The inner loop is also convertible. Nested<S> NestS; for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { for (S::const_iterator SI = (*I).begin(), SE = (*I).end(); SI != SE; ++SI) { printf("%d", *SI); } } // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto I : NestS) // CHECK-FIXES-NEXT: for (S::const_iterator SI = I.begin(), SE = I.end(); SI != SE; ++SI) // CHECK-FIXES-NEXT: printf("%d", *SI); for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { const S &Ss = *I; for (S::const_iterator SI = Ss.begin(), SE = Ss.end(); SI != SE; ++SI) { printf("%d", *SI); const_g(SI); } } // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto Ss : NestS) for (Nested<S>::iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { S &Ss = *I; for (S::iterator SI = Ss.begin(), SE = Ss.end(); SI != SE; ++SI) { printf("%d", *SI); g(SI); } } // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto & Ss : NestS) Foo foo; for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { const S &Ss = *I; for (S::const_iterator SI = Ss.begin(), SE = Ss.end(); SI != SE; ++SI) { printf("%d", *SI); foo.const_g(SI); } } // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto Ss : NestS) for (Nested<S>::iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { S &Ss = *I; for (S::iterator SI = Ss.begin(), SE = Ss.end(); SI != SE; ++SI) { printf("%d", *SI); foo.g(SI); } } // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto & Ss : NestS) }
int main(int argc, char* argv[]) { Foo foo; Student st1; Student st2; Student st3; st1.sName = "辉辉"; st1.age = 25; st1.score = 24; st2.sName = "老K"; st2.age = 26; st2.score = 25; st3.sName = "叶枫"; st3.age = 27; st3.score = 26; foo.vec.push_back(st1); foo.vec.push_back(st2); foo.vec.push_back(st3); foo.ls.push_back(st1); foo.ls.push_back(st2); foo.ls.push_back(st3); foo.st.emplace(st1); foo.st.emplace(st2); foo.st.emplace(st3); foo.deq.push_back(st1); foo.deq.push_back(st2); foo.deq.push_back(st3); foo.mp.insert({st1.sName, st1}); foo.mp.insert({ st2.sName, st2 }); foo.mp.insert({ st3.sName, st3 }); foo.un_mp.insert({ st1.sName, st1 }); foo.un_mp.insert({ st2.sName, st2 }); foo.un_mp.insert({ st3.sName, st3 }); foo.set.insert(st1); foo.set.insert(st2); foo.set.insert(st3); foo.un_set.insert(st1); foo.un_set.insert(st2); foo.un_set.insert(st3); Serialization::OutputArchive<Serialization::YamlOutputArchive, false> outputArchiveYaml; Serialization::OutputArchive<Serialization::JsonOutPutArchive, false> outputArchiveJson; Serialization::OutputArchive<Serialization::XmlOutPutArchive, false> outputArchiveXml; outputArchiveYaml << foo; outputArchiveJson << foo; outputArchiveXml << foo; std::string sYaml = outputArchiveYaml.c_str(); std::string sJson = outputArchiveJson.c_str(); std::string sXml = outputArchiveXml.c_str(); foo.Clear(); Serialization::InputArchive<Serialization::JsonInPutArchive, false> iArchiveJson; Serialization::InputArchive<Serialization::YamlInputArchive, false> iArchiveYaml; Serialization::InputArchive<Serialization::XmlInPutArchive, false> iArchiveXml; iArchiveJson.Load(sJson); iArchiveJson >> foo; foo.Clear(); iArchiveYaml.Load(sYaml); iArchiveYaml >> foo; foo.Clear(); iArchiveXml.Load(sXml); iArchiveXml >> foo; getchar(); return 0; }
bool check_something() { Foo f; f.hello(); }
void foo_says(const Foo& foo) { foo.say(); }
void Bar() { Foo f; f.Bar(); // expected-warning {{ignoring return value}} };
static void benchmarkFunctionsWithParameters(void) { Foo foo; EventSPtr event_sptr = std::make_shared<TestEvent>(); std::function<void(EventSPtr)> memFunc1 = std::bind(&Foo::memFunc2, &foo, std::placeholders::_1); ssvu::FastFunc<void(EventSPtr)> memFunc2 = ssvu::FastFunc<void(EventSPtr)>(&foo, &Foo::memFunc2); fastdelegate_org::FastDelegate<void(EventSPtr)> memFunc3 = fastdelegate_org::bind(&Foo::memFunc2, &foo, std::placeholders::_1); fastdelegate::FastDelegate<void(EventSPtr)> memFunc4 = fastdelegate::MakeDelegate(&foo, &Foo::memFunc2); generic::delegate<void(EventSPtr)> memFunc5 = generic::delegate<void(EventSPtr)>::from<Foo, &Foo::memFunc2>(&foo); std::function<void(EventSPtr)> staticClassFunc1 = std::bind(&Foo::staticMemFunc2, std::placeholders::_1); ssvu::FastFunc<void(EventSPtr)> staticClassFunc2 = ssvu::FastFunc<void(EventSPtr)>(&Foo::staticMemFunc2); fastdelegate_org::FastDelegate1<EventSPtr> staticClassFunc3 = fastdelegate_org::FastDelegate1<EventSPtr>(&Foo::staticMemFunc2); fastdelegate::FastDelegate<void(EventSPtr)> staticClassFunc4 = fastdelegate::MakeDelegate(&Foo::staticMemFunc2); generic::delegate<void(EventSPtr)> staticClassFunc5 = generic::delegate<void(EventSPtr)>::from<&Foo::staticMemFunc2>(); std::function<void(EventSPtr)> staticGlobalFunc1 = std::bind(&::staticGlobalFunc2, std::placeholders::_1); ssvu::FastFunc<void(EventSPtr)> staticGlobalFunc2 = ssvu::FastFunc<void(EventSPtr)>(&::staticGlobalFunc2); fastdelegate_org::FastDelegate1<EventSPtr> staticGlobalFunc3 = fastdelegate_org::FastDelegate1<EventSPtr>(&::staticGlobalFunc2); fastdelegate::FastDelegate<void(EventSPtr)> staticGlobalFunc4 = fastdelegate::MakeDelegate(&::staticGlobalFunc2); generic::delegate<void(EventSPtr)> staticGlobalFunc5 = generic::delegate<void(EventSPtr)>::from<&::staticGlobalFunc2>(); ::newLine(); ::writeLine("[member function]"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) foo.memFunc2(event_sptr); ::endBenchmark("raw"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) memFunc1(event_sptr); ::endBenchmark("std::function"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) memFunc2(event_sptr); ::endBenchmark("ssuv::FastFunc"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) memFunc3(event_sptr); ::endBenchmark("FastDelegate"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) memFunc4(event_sptr); ::endBenchmark("FastDelegate C++11"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) memFunc5(event_sptr); ::endBenchmark("SR Delegate C++11"); ::newLine(); ::writeLine("[static class function]"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) Foo::staticMemFunc2(event_sptr); ::endBenchmark("raw"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) staticClassFunc1(event_sptr); ::endBenchmark("std::function"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) staticClassFunc2(event_sptr); ::endBenchmark("ssuv::FastFunc"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) staticClassFunc3(event_sptr); ::endBenchmark("FastDelegate"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) staticClassFunc4(event_sptr); ::endBenchmark("FastDelegate C++11"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) staticClassFunc5(event_sptr); ::endBenchmark("SR Delegate C++11"); ::newLine(); ::writeLine("[static global function]"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) ::staticGlobalFunc2(event_sptr); ::endBenchmark("raw"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) staticGlobalFunc1(event_sptr); ::endBenchmark("std::function"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) staticGlobalFunc2(event_sptr); ::endBenchmark("ssuv::FastFunc"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) staticGlobalFunc3(event_sptr); ::endBenchmark("FastDelegate"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) staticGlobalFunc4(event_sptr); ::endBenchmark("FastDelegate C++11"); ::beginBenchmark(); for (int i = 0; i < ITERATION_COUNT; ++i) staticGlobalFunc5(event_sptr); ::endBenchmark("SR Delegate C++11"); ::newLine(); }