Boost logo

Boost :

Subject: Re: [boost] [Boost.Local] Review
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2011-11-23 05:06:53


Le 19/11/2011 01:18, Lorenzo Caminiti a écrit :
> However, there are many other Boost libraries that use a macro API to
> save the application writes from writing boiler-plate code

Most of them are there to emulate a now C++11 facility or even better
actually pushed for the same C+11 facility.

> With respect to other libraries, there is no other Boost library (and
> no other library in general at least that I know of) that allows you
> to write local functions while retaining statement syntax for the
> function definition.

The problem is that there is no need for C++ local function IMHO.

> It is true that if you have C++11 lambdas you will probably use those
> over Boost.Local closures. However, if you need to write code that
> works on both C++11 and C++03 and performs like C++11 lambdas on
> C++11, Boost.Local helps you there.

C++03 is C++03, could be good for everybody if the C++11 bandwagon was
jumped on by more people. Havign boost starting to provide C++11 based
library could be the bootstrap C++11 require. Bootstrap that will ensure
compiler vendors care about the new standard.

> int max = 0;
> bool BOOST_LOCAL_FUNCTION_PARAMS(int x, const bind max) {
> return x< a;
> } BOOST_LOCAL_FUNCTION_NAME(small)
> small(10);

just using phoenix and/or lambda :

int max = 0;
auto small = _1 < max;

local functions could be nice fi you have huge ones. One liners becomes
nightmares and if you have a huge local function, make it a function.


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