|
Boost Users : |
From: Darren Garvey (lists.drrngrvy_at_[hidden])
Date: 2007-06-20 12:30:47
Hi Mojmir,
On 20/06/07, Mojmir Svoboda <mojmir.svoboda_at_[hidden]> 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
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