title: Boost.Bind to access std::map elements in std::for_each
body: <p>I've got a map that stores a simple struct with a key. The struct has two member functions, one is const the other not. I've managed calling the const function using std::for_each without any problems, but I've got some problems calling the non-const function.</p>
  
  <pre><code>struct MyStruct {
    void someConstFunction() const;
    void someFunction();
  };
  
  typedef std::map&lt;int, MyStruct&gt; MyMap;
  MyMap theMap;
  
  //call the const member function
  std::for_each(theMap.begin(), theMap.end(),
     boost::bind(&amp;MyStruct::someConstFunction, boost::bind(&amp;MyMap::value_type::second, _1)));
  
  //call the non-const member function
  std::for_each(theMap.begin(), theMap.end(),
     boost::bind(&amp;MyStruct::someFunction, boost::bind(&amp;MyMap::value_type::second, _1)));
  </code></pre>
  
  <p>The call to the const member function works fine, but it seems boost internally expects a const MyStruct somewhere, and thus fails with the following compilation error in MSVC7.1.</p>
  
  <blockquote>
    <p>boost\bind\mem_fn_template.hpp(151): error C2440: 'argument' : cannot convert from 'const MyStruct *__w64 ' to 'MyStruct *const '</p>
  </blockquote>
  
  <p>I'd appreciate any help on how to set the template parameters correctly, so bind does recognize the parameters correctly and let me call the non const function.</p>
  
  <p>thanks,
  Carl</p>