title: boost function and lambda to wrap a function
body: <p>I want to convert this simple code:</p>
  
  <pre><code>void setZComp(Imath::V3f&amp; pt)
  {
      pt.z = 0.0;
  }
  
  int myfunc()
  {
      ...
  
      std::vector&lt;Imath::V3f&gt; vec(5,Imath::V3f(1.0,1.0,1.0));
      std::for_each(vec.begin(),vec.end(),boost::bind(&amp;setZComp,_1));
  
      ...
  }
  </code></pre>
  
  <p>to something like that, in order to not have setZComp declared outside but some sort of inline declaration</p>
  
  <pre><code>int myfunc()
  {
      ...
  
      boost::function&lt;double(Imath::V3f&amp;)&gt; f = (boost::lambda::_1 -&gt;* &amp;Imath::V3f::z = 0.0) ;
      std::for_each(vec.begin(),vec.end(),boost::bind(&amp;f,_1));
  
      ...
  }
  </code></pre>
  
  <p>I'm quite new to Boost Bind and Lambda and I don't know if this can be done in some way. Obviously the code above does not work.</p>