Boost logo

Boost :

From: Michiel Salters (michiel.salters_at_[hidden])
Date: 2004-11-09 06:45:26


The boost::function template works with boost::ref according to the docs,
so try boost::function< int ( int ) > ( boost::ref( Op() ) )

HTH,
Michiel Salters

> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]]On Behalf Of Neal D. Becker
> Sent: maandag 8 november 2004 16:16
> To: boost_at_[hidden]
> Subject: [boost] boost::ref simple question
>
>
> This must be a common question.
>
> I want to use std::transform with a function object that is
> expensive to
> copy, so I want to pass by reference. I tried to use
> boost::ref for this,
> but this simple test doesn't work:
>
> struct Op {
> int operator() (int x) { return 1 + x;}
> Op() {}
> private:
> Op (const Op&);
>
> };
>
> int main() {
> vector<int> x (4);
> vector<int> y (4);
> Op o;
> std::transform (x.begin(), x.end(), y.begin(), boost::ref(o));
> }
>
> Any suggestion?
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk