Boost logo

Boost :

Subject: [boost] [local] What do you think of the new syntax?
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2011-02-27 22:07:33


Hello all,

Before I spend 2+ weeks updating Boost.Local docs... can you please
express an opinion about Boost.Local new and simplified syntax?

If variadic macros are supported by your compiler:

 #include <boost/local/function.hpp>
 #include <iostream>

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

    void BOOST_LOCAL_FUNCTION_PARAMS(double num, const bind factor,
            bind& sum) {
        sum += factor * num;
        std::clog << "Summed: " << sum << std::endl;
    } BOOST_LOCAL_FUNCTION_NAME(add)

    add(100.0);
    return 0;
 }

On all compilers (with variadic macros or not):

 #include <boost/local/function.hpp>
 #include <iostream>

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

    void BOOST_LOCAL_FUNCTION_PARAMS( (double num) (const bind factor)
            (bind& sum) ) {
        sum += factor * num;
        std::clog << "Summed: " << sum << std::endl;
    } BOOST_LOCAL_FUNCTION_NAME(add)

    add(100.0);
    return 0;
 }

See also http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/index.html#boost_local.Introduction.an_example

Thanks a lot.

-- 
Lorenzo

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