Boost logo

Boost :

Subject: Re: [boost] New libraries implementing C++11 features in C++03
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2011-11-25 05:33:01

On Thu, Nov 24, 2011 at 9:58 PM, Dean Michael Berris
<mikhailberis_at_[hidden]> wrote:
> On Fri, Nov 25, 2011 at 7:36 AM, Lorenzo Caminiti <lorcaminiti_at_[hidden]> wrote:
>> On Thu, Nov 24, 2011 at 12:56 PM, Thomas Klimpel
>> <Thomas.Klimpel_at_[hidden]> wrote:
>>> Dean Michael Berris wrote:
>>>> Or better yet, works now:
>>>> namespace foo {
>>>>   void non_local_function(int i, bool b, long l, std::string const & s)

Actually, I have tried to rework this example so I don't have to
specify the type of i, b, l and I wasn't able too (without starting to
re-implement the type deduction mechanisms that Local uses). Can you
please show me how you will do that without the explicit bound types?
(That will make maintenance easier given that you don't need to change
the "local function" if you change the bound variable types which is
true for any closure.)

>>>> {
>>>>     // do what I want here.
>>>>   }
>>>>   void f(std::vector<double> const &v) {
>>>>     int i;
>>>>     bool b;
>>>>     long l;
>>>>     for_each(begin(v), end(v), bind(&non_local_function, i, b, l, _1));
>>>>   }
>>>> }
>>>> See, no voodoo required here.
>>> To be honest, this one really looks nice and convincing. I find it even looks nicer than the C++11 Lambda. And as you wrote in response to Lorenzo:
>>>> But I did show a solution that works in both C++03 and C++11 which is
>>>> to use bind to do it and a non-local function. Phoenix already enables
>> As you say this solution, which works on both C++03 and C++11, does
>> not implement a local function. N2511 indicates one prospective
>> arguing maintenance and readability benefits when the function can be
>> declared locally, e.g., just above the for_each in this case. That is
>> not possible in your example. That's what Boost.Local does instead.
>> (Note that with your example above you also explicitly specified the
>> bound types but I'm sure you can workaround that with templates so I'm
>> not arguing this point as an issue.)
> Am I missing something here, N2511 was sent in 2008 and lambda's
> already are in C++11 which already encompass the capabilities defined
> in N2511. Why do we keep coming back to N2511 when C++11 is already
> out?

For C++03 which does not support lambdas. Again there other Boost
libraries that implement C++11 features for C++03, why would the
situation be different for Local?

>>> - What is your evaluation of the potential usefulness of the library?
> If you really want to know, I think there's absolutely 0 potential
> usefulness of this library given what's already there in C++03 and

It's not already there in C++03 because in C++03 you cannot 1) declare
a function locally, 2) binding variables, and 3) using statement
syntax for its body. However, I see you statement that yo don't care
about 1-2-3. So the point it is not that it's that 1-2-3 are already
in C++03, because they are not, it is instead that you (personally)
don't need 1-2-3.

> C++11 to be included in Boost.


Boost list run by bdawes at, gregod at, cpdaniel at, john at