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;

    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;

    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;

    return 0;

Source code:

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
5. Added BOOST_LOCAL_FUNCTION_NAME(inline ...) and
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:


Boost list run by bdawes at, gregod at, cpdaniel at, john at