Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-04-16 17:31:09


Eric MALENFANT wrote:

> 2)
> var_type<std::string>::type temp(var(std::string()));
>
> std::for_each(
> begin, end,
> bind(Print,
> bind(&std::string::c_str,
> (temp = bind(&A::name, _1))
> )
> )
> );
>
> Note that this is more "for fun" than, anything.

In the "for fun" spirit, here's the boost::bind equivalent:

    string& (string::*assign)( string const & ) = &string::operator=;

    std::for_each(
        begin, end,
        bind( Print,
            bind( &std::string::c_str,
                bind( assign, string(), bind( &A::name, _1 ) )
            )
        )
    );


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net