How to dereference an iterator using boost::bind

S

Stone Free

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::pair<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::partitionActiveUsers()
{
//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))));
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,342
Messages
2,571,407
Members
48,796
Latest member
katerack

Latest Threads

Top