Boost logo

Boost :

Subject: Re: [boost] [Boost-users] [Fit] formal review starts today
From: work (Vladimir.Batov_at_[hidden])
Date: 2016-03-09 03:13:31


On 2016-03-09 18:34, paul Fultz wrote:
>> On Tuesday, March 8, 2016 4:58 PM, Vladimir Batov
>> <Vladimir.Batov_at_[hidden]> wrote:
>
> Maybe I need a little more explanation of components in the Quick Start
> Guide.
> Perhaps, also, a comparison of writing some of the examples without
> using the
> library...

I think that's an excellent idea.

>> ... a functor. I
>> think it happens pretty much automatically.
>
> Well, the library provides help for that as well, because currently in
> C++ you
> can't pass generic functions to other functions, like this:
>
> std::accumulate(v.begin(), v.end(), 0, std::max); // Compile error
> However, BOOST_FIT_LIFT will let you do that:
>
> std::accumulate(v.begin(), v.end(), 0, BOOST_FIT_LIFT(std::max));

Isn't it resolved with

std::accumulate(v.begin(), v.end(), 0, boost::bind(std::max<int>, _1,
_2));

Seems like std binders take care of the generic functions'
"awkwardness". Am I missing anything?

>> "if we construct the class as a global variable"
>>
>> Should I be excited about it? Globals are often a royal pain. Do I
>> want
>
>> to construct it a a global variable?
>
> Whats the pain about these Global variables? They are const, can be
> namespaced, and work just like free functions. However, they do have
> several
> advantages.

I much prefer creating things locally to minimize the scope and the
potential for mis-use. If I (or someone) create something (an object),
there is a potential desire to stick some stateful info/data into it.
Then, the complexity snow-balls as it becomes a bottleneck in
multi-threaded env.
>
> First, by making them objects we can turn functions into first-class
> citizens.

Why can't I use the standard binders to achieve that?.. Or what do I
gain by using Fit instead?

> skipped considerable chunk...

What I seem to hear is that Fit helps to overcome some plain-function
limitations. I think you might want to consider highlighting what Fit
adds compared to the standard binders. I felt that quite a few of your
examples could be done using those binders. I might be wrong though.

V.


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