Boost logo

Boost :

Subject: [boost] [local] Review request
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2011-05-14 15:38:50


Hello all,

I happy to announce that I have released Boost.Local 0.2.0
incorporating the many valuable suggestions that I have received from
this mailing list.

I would like to request to add Boost.Local to the review schedule and
for any volunteer to be the review manager. Thank you!

Boost.Local supports local functions, local blocks, and local exits
for C++. For example:

#include <boost/local/function.hpp>
#include <boost/local/block.hpp>
#include <boost/local/exit.hpp>

#include <algorithm>
#include <iostream>
#include <cassert>

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::cout << "Summed: " << sum << std::endl;
    } BOOST_LOCAL_FUNCTION_NAME(add)
    add(100.0);

    size_t size = 2;
    double* nums = new double[size];
    BOOST_LOCAL_EXIT(const bind& size, bind nums) {
        if (size && nums) delete[] nums;
        std::cout << "Freed array: " << nums << std::endl;
    } BOOST_LOCAL_EXIT_END

    nums[0] = 90.5; nums[1] = 7.0;
    std::for_each(nums, nums + size, add); // `add` as template parameter

    BOOST_LOCAL_BLOCK(const bind& sum) {
        assert(sum == 1975.0); // so far `sum` is 10*100+10*90.5+10*7=1975
        std::cout << "Asserted summation: " << sum << std::endl;
    } BOOST_LOCAL_BLOCK_END

    return 0;
}

Documentation: http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/index.html
Source code: http://svn.boost.org/svn/boost/sandbox/local/

Release Notes for Version 0.2.0 (2011-05-14)
1. Replaced parenthesized syntax with variadic and sequencing macro syntaxes.
2. Profiled library performances against other approaches.
3. Replaced virtual functor trick with casting functor trick (for
smaller run-time).
4. Optimized library run-time (rearranging code and not using casting
functor trick on compilers that accept local classes as template
parameters).
5. Added BOOST_LOCAL_FUNCTION_NAME(inline ...) and
BOOST_LOCAL_FUNCTION_NAME(recursive ...).
6. Added BOOST_LOCAL_TYPEOF.
7. Added bind(type) to specify bind type explicitly (skipping
Boost.Typeof type deduction).
8. Removed boost::local::function (use boost::function instead).
9. Added boost::local::function::overload to overload local functions
(and functors in general).
10. Implemented support for nesting local functions, blocks, and exits
into one another.

Boost.Local was used by Gregory Crosswhite in one of his project:
https://github.com/gcross/CodeSearch

-- 
Lorenzo

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