ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

void MemFunPtrTest::find ( ) [protected]

Definition at line 193 of file mfunptr_test.cpp.

{
#if !defined (STLPORT) || defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
  vector<V> v;

  v.push_back( V(1) );
  v.push_back( V(2) );
  v.push_back( V(3) );

  // step-by-step complication of work for compiler:

  // step 1:
  const_mem_fun1_ref_t<bool,V,int> pmf = mem_fun_ref( &V::f );
  binder2nd<const_mem_fun1_ref_t<bool,V,int> > b(pmf, 2);
  vector<V>::iterator i = find_if( v.begin(), v.end(), b );
  CPPUNIT_ASSERT(i != v.end());
  CPPUNIT_ASSERT(i->v == 2);

  // step 2, just check that compiler understand what pass to bind2nd:
  binder2nd<const_mem_fun1_ref_t<bool,V,int> > b2 = bind2nd( pmf, 2 );

  // step 3, the same as step 1, but more intellect from compiler required:
  binder2nd<const_mem_fun1_ref_t<bool,V,int> > b3 = bind2nd( mem_fun_ref( &V::f ), 2 );

  vector<V>::iterator j = find_if( v.begin(), v.end(), b3 );
  CPPUNIT_ASSERT(j != v.end());
  CPPUNIT_ASSERT(j->v == 2);

  // step 4, more brief, more complex:
  vector<V>::iterator k = find_if( v.begin(), v.end(), bind2nd( mem_fun_ref( &V::f ), 2 ) );
  CPPUNIT_ASSERT(k != v.end());
  CPPUNIT_ASSERT(k->v == 2);
#endif
}

Generated on Sat May 26 2012 06:29:30 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.