Boost logo

Boost :

Subject: Re: [boost] painless currying
From: Larry Evans (cppljevans_at_[hidden])
Date: 2011-09-03 09:38:05


On 09/03/11 08:28, Larry Evans wrote:
[snip]
> With the 2 attached files (compiled with gcc4.6 and with boost trunk
> [which svn update showed was revision 74198]), the output is:
>
[snip]
> which shows several copy CTOR's executed. These copy CTOR
> calls were caused by the code like this:
>
> curryable (Fun f, Arg0 a0, Arg1 a1, Arg2 a2):
> fun (f),
> arg0 (a0),
> arg1 (a1),
> arg2 (a2)
> {
> }
>
> produced by the BOOST_PP code. Is there any way to prevent
> these copies, maybe by declarations like:
>
> Arg0 const&
> arg0;
>
> instead of the existing:
>
> Arg0
> arg0;
>
> ?
>
[snip]
OOPS. I should have thought a bit more. The reason:

  Arg0 const& arg0;

won't work is because the arguments to the curryable CTOR:

  curryable (Fun f, Arg0 a0):

maybe be gone by the time f is actually called, and that's
why they have to be copied.

Sorry for noise :(

-Larry


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