[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: instantiating boost::bind(...) in one place and reusing it throughou
From: |
er |
Subject: |
Re: instantiating boost::bind(...) in one place and reusing it throughout the code |
Date: |
Fri, 05 Oct 2007 14:03:36 -0700 |
User-agent: |
G2/1.0 |
On Oct 1, 12:24 pm, Pedro Lamarão <pedro.lama...@gmail.com> wrote:
> On Sep 29, 8:37 pm, er <erwann.rog...@gmail.com> wrote:
>
> > hi,
>
> > for example, i use
>
> > boost::bind(
> > &A::f,
> > _1
> > )
>
> > in different parts of my code. i'm thinking of using something like
>
> > some_type* fo = new boost::bind(&A::f,_1);
>
> > and use *fo in place of boost::bind(...). is this ok? what should
> > some_type be?
>
> This is a question most suited for the Boost Users mailing list.
>
> Check the Boost website.
>
> http://www.boost.org/
>
> --
> Pedro Lamarão
thanks, news://news.gmane.org/gmane.comp.lib.boost.user helped, but
still have a problem:
boost::function<void(const boost::shared_ptr<A>&)> deref =
boost::bind(&boost::shared_ptr<A>::operator*, _1);
Functor ftor;
std::vector<boost::shared_ptr<A> > vec = ...;
for_each(
vec.begin(),
vec.end(),
boost::bind(
boost::ref(ftor),
boost::bind(&boost::shared_ptr<A>::operator*, _1)
)
);//fine
for_each(
vec.begin(),
vec.end(),
boost::bind(
boost::ref(ftor),
deref
)
);//not fine. see error below
//no match for call to '(Functor) (boost::function<void ()(const
//boost::shared_ptr<A>&), std::allocator<void> >&)