
Hi Mojmir, On 20/06/07, Mojmir Svoboda <mojmir.svoboda@logicacmg.com> wrote:
Hello,
i want to use bind to create a pair and forward it to an std::ostream, i.e. like:
std::for_each(vec.begin(), vec.end(), bind(&write, std::cout, bind(constructor<std::pair<value_t, value_t> >(), _1, _1)));
but the compiler says: ios_base.h:781: error: 'ios_base(const ios_base &)' is private boost/boost/lambda/detail/bind_functions.hpp:472: error: within this context boost/boost/lambda/detail/function_adaptors.hpp: In static member function `static void boost::lambda::function_adaptor< void (*)(ostream &, const pair<value_t, value_t> &) >::apply( void (*)(ostream &, const pair<value_t, value_t> &), const ostream &, const pair<value_t, value_t> &)' ... it seem that temporary is created? why? how to avoid it?
Have you tried: std::for_each(vec.begin(), vec.end(), bind(&write, boost::ref(std::cout), // !! bind(constructor<std::pair<value_t, value_t> >(), _1, _1))); ? That stops bind taking a copy of std::cout, which should fix the first problem. -- Darren