+ Reply to Thread
Results 1 to 2 of 2

Thread: Simple predicate example.

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    49

    Simple predicate example.

    Simple predicate example.

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    Example:

    Code:
    #include <vector>
    #include <algorithm>
    #include <functional>
    
    bool GreaterThan10(int nValue)
    {
    	return (nValue > 10) ? true : false ;
    }
    
    void UseSimplePredicate()
    {
    	typedef std::vector<int> VECTOR_INT_TYPE ;
    
    	VECTOR_INT_TYPE vInts ;
    
    	for(int nIndex=0; nIndex<20; nIndex++)
    	{
    		vInts.push_back(nIndex) ;
    	}
    
    
    	VECTOR_INT_TYPE::const_iterator itr = std::find_if(vInts.begin(), vInts.end(), GreaterThan10) ;
    
    	for (; itr != vInts.end(); itr++)
    	{
    		char szMessage[100] ;
    		sprintf(szMessage, "Item = %d", *itr) ;
    	}
    
    	vInts.clear() ;
    }

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts