Boost logo

Boost Users :

From: steve ahlgren (steveahlgren_at_[hidden])
Date: 2005-04-20 16:24:46


Hello :

Try using boost::ref to avoid creating a copy of the arguments (see
http://www.boost.org/doc/html/ref.html ) :

std::for_each( rr.begin(),
                                rr.end(),
                                boost::bind( boost::mem_fn( &Region::render ),
                                                        _1,
                                                        boost::ref( ltt ),
                                                        foo,
                                                        boost::ref( si )
                                                        )
                                );

Good luck!

On 4/20/05, Mathieu De Zutter <mathieu_at_[hidden]> wrote:
> Hi,
>
> I have some code that runs fine:
>
> for (Partition::iterator pi = renderRegions.begin(); pi !=
> renderRegions.end(); ++pi);
> (*pi)->render(&ltt, foo, si);
>
> I try to replace it by for_each & boost::bind,
>
> std::for_each(renderRegions.begin(), renderRegions.end(),
> boost::bind(&Region::render, _1, &ltt, foo, si));
>
> but si doesn't get modified, while it should be passed as reference.
>
> Some more relevant code:
>
> class Region
> {
> ...
> void render(const LightTransportType* ltt, WorkAppraiser& wa,
> image::SampleImage& result);
> ...
> };
>
> typedef std::vector< Region* > Partition;
> Partition renderRegions;
>
> Is this normal behaviour?
>
> --
> With kind regards,
> Mathieu
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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