Boost logo

Boost :

Subject: Re: [boost] [local] Help for the Alternatives section
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2011-03-27 10:04:32


On Saturday, March 26, 2011 11:19:46 PM Lorenzo Caminiti wrote:
> Hello all,
>
> I am updating Boost.Local docs and I could use a some help in getting
> the Alternatives section right
>
http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Alternatives.html

I would really like to see the first row removed ...
All alternatives you describe are using C++ syntax ... I know what you mean. But
all the examples use regular C++ syntax.

Another thing what i really wonder is: You write that local classes can not be
passed as a template parameter.
I don't really get the difference between the local class and Boost.Local.
What about this:

int main() {
    double sum = 0.0;
    int factor = 10;

    struct add_impl {
        double & sum;
        int const& factor;
        add_impl(double sum, int factor) : sum(sum), factor(factor) {}

        void operator()(double num) const
        {
            sum += factor * num;
            std::clog << "Summed: " << sum << std::endl;
        }
    };

    boost::function<void(double)> add = add_impl(sum, factor);

    double nums[3] = {1, 2, 3};
    std::for_each(nums, nums + 3, add)
    return 0;
}

I would be happy if you sched some light on to why this isn't possible but why
its possible with using your macros.


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