Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > How to dereference an iterator using boost::bind

Reply
Thread Tools

How to dereference an iterator using boost::bind

 
 
Stone Free
Guest
Posts: n/a
 
      09-23-2009
If I have a routine that partitions a vector based on the data
recorded in a supplemental map, and the preconditions to entering the
routine are that every element in the vector exists in the map. How
do I do the following exclusively using boost::bind?

#include "stdafx.h"
#include <string>
#include <map>
#include <vector>
#include <functional>
#include <algorithm>
#include <boost/bind.hpp>


typedef int DWORD;
typedef std:air<std::string, bool> user_info;
typedef std::map<DWORD, user_info> USER_MAP;
typedef std::vector<DWORD> VEC_STAFF;


struct current_user_check
: public std::unary_function<USER_MAP::const_iterator, bool>
{
bool operator()(const argument_type & val) const
{
return val->second.second;
}
};

void SomeObject:artitionActiveUsers()
{
//m_users - Gathers staff details from DB
//m_users.GetStaff(); returns a vector of IDs
//USER_MAP m_Users;
//...

VEC_STAFF Staff;//(m_users.GetStaff());
VEC_STAFF::const_iterator itCurEnd = stable_partition(Staff.begin(),
Staff.end(), (boost::bind(current_user_check(), boost::bind
(&USER_MAP::find, &m_Users, _1))));
}

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: How to "dereference" an iterator? Carsten Haese Python 1 10-11-2007 02:46 AM
How does dereference operator overloading really work? Joe Seigh C++ 18 09-22-2003 05:42 PM
Re: how to properly dereference STL list item Howard C++ 0 07-01-2003 05:46 PM
Re: how to properly dereference STL list item Jakob Bieling C++ 0 07-01-2003 05:45 PM



Advertisments