Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. boost bind expression not doing what I expect

boost bind expression not doing what I expect

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialgraphicsalgorithmsannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stone Free
    wrote on last edited by
    #1

    I obviously don't get this bind stuff as I cannot seem to get it right

    #include <map>
    #include <set>
    #include <vector>
    #include <algorithm>
    #include <boost/bind.hpp>

    using namespace boost::bind;

    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;

    int _tmain(int argc, _TCHAR* argv[])
    {
    USER_MAP m_Users;
    VEC_STAFF Staff;

    VEC\_STAFF::iterator it = std::partition(Staff.begin(), Staff.end(),(bind(&USER\_MAP::find, m\_Users, \_1) != m\_Users.end()));
    

    What I wanted to code to do is that for every entry in the Staff vector it should check to see whether that user id was present in the map, and if so move those items to the front. I have an example using a functor that works as I hoped the above code would, but the bind version is obviously not doing what I think its doing.

    struct InUsersMap : public std::unary_function<USER_MAP::key_type,bool>
    {
    InUsersMap(USER_MAP & theMap, USER_MAP::const_iterator end)
    : m_theMap(theMap)
    {
    }
    inline bool operator()(CSecurePatients::USER_MAP::key_type& id) const
    {
    return m_theMap.find(id) != m_theMap.end();
    }
    private:
    const USER_MAP &m_theMap;
    }

    Finally does anyone know how to avoid getting the socket bind function from windows being included

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups