How to dereference an iterator using boost::bind
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))));
}