Boost logo

Boost :

Subject: Re: [boost] [bind] Boost.Bind compile error with msvc-11 and msvc-10
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2013-02-13 16:25:55


> From: lists_at_[hidden]
> To: boost_at_[hidden]
> Date: Wed, 13 Feb 2013 20:53:34 +0200
> Subject: Re: [boost] [bind] Boost.Bind compile error with msvc-11 and msvc-10
>
> Ian Emmons wrote:
> > Peter and Stephan, thanks for the information. It looks like I should
> > write my own functor rather than use Boost.Bind in this case.
>
> You could still use bind with your own functor, if you like. :-)
>
> struct my_push_back
> {
> template<class C, class T> void operator()( C & c, T & v ) const
> {
> c.push_back( v );
> }
> };
>
> and then
>
> boost::bind( my_push_back(), boost::ref( strList ), _1 );

I find Boost.Phoenix really useful in cases like this, because it comes
with out-of-the-box support for lazy wrappers for STL functions:

#include <boost/phoenix/core.hpp>
#include <boost/phoenix/stl.hpp>
...
using boost::phoenix::arg_names::_1;
...
x.enumerateStrings(phoenix::push_back(phoenix::ref(strList), _1));

Full example attached. I don't have MSVC handy to try it out, but
it compiles with GCC, and it solves the problem that was causing
your example to fail to compile, so it should work.

Regards,
Nate

                                               



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk