$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r67932 - sandbox/local/libs/local/example
From: lorcaminiti_at_[hidden]
Date: 2011-01-10 16:12:34
Author: lcaminiti
Date: 2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
New Revision: 67932
URL: http://svn.boost.org/trac/boost/changeset/67932
Log:
Added example files.
Added:
   sandbox/local/libs/local/example/add.cpp   (contents, props changed)
   sandbox/local/libs/local/example/add_block.cpp   (contents, props changed)
   sandbox/local/libs/local/example/add_except.cpp   (contents, props changed)
   sandbox/local/libs/local/example/add_exit.cpp   (contents, props changed)
   sandbox/local/libs/local/example/add_num.cpp   (contents, props changed)
   sandbox/local/libs/local/example/add_num_factor_sum.cpp   (contents, props changed)
   sandbox/local/libs/local/example/add_num_sum.cpp   (contents, props changed)
   sandbox/local/libs/local/example/add_optimizers.cpp   (contents, props changed)
   sandbox/local/libs/local/example/add_template.cpp   (contents, props changed)
   sandbox/local/libs/local/example/add_this.cpp   (contents, props changed)
   sandbox/local/libs/local/example/block.cpp   (contents, props changed)
   sandbox/local/libs/local/example/doit.cpp   (contents, props changed)
   sandbox/local/libs/local/example/exit.cpp   (contents, props changed)
   sandbox/local/libs/local/example/factorial.cpp   (contents, props changed)
   sandbox/local/libs/local/example/find_if.cpp   (contents, props changed)
   sandbox/local/libs/local/example/jamfile.jam   (contents, props changed)
   sandbox/local/libs/local/example/params.cpp   (contents, props changed)
   sandbox/local/libs/local/example/print_map.cpp   (contents, props changed)
   sandbox/local/libs/local/example/renamed_exit.cpp   (contents, props changed)
   sandbox/local/libs/local/example/renamed_print.cpp   (contents, props changed)
   sandbox/local/libs/local/example/same_line.cpp   (contents, props changed)
   sandbox/local/libs/local/example/this.cpp   (contents, props changed)
   sandbox/local/libs/local/example/transform.cpp   (contents, props changed)
Properties modified: 
   sandbox/local/libs/local/example/   (props changed)
Added: sandbox/local/libs/local/example/add.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,61 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Use all local constructs -- main motivating example for the documentation.
+// Adapted from C++0x lambda paper N2529 (added local blocks and exits).
+    
+// NOTE: In this example `factor` is bound as const reference so to prevent
+// the local function to modify it. Alternatively, it could have been bound by
+// value as in `(bind)( (&sum) (factor) )` so to prevent modifications of
+// `factor` from within the local function to affect `factor` values outside
+// the local function scope (as done in N2529). However, binding `factor` by
+// value instead that as const reference would have introduced an extra copy
+// operation and, more importantly, it would have not enforced the logical
+// constraint that `factor` should not be modified at all from within the local
+// function body.
+
+//[ add_cpp
+/*< Include the header files for this library local functions, local blocks, and local exits. >*/
+#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;
+
+    BOOST_LOCAL_FUNCTION( /*< The *local function* declaration macro. This macro takes one parameter specifying the local function signature using the /parenthesized syntax/. This syntax resembles the usual C++ function declaration syntax but it wraps all tokens within parenthesis (see the __Tutorial__ section). The parenthesized syntax for local functions introduces the new "keyword" `bind` which is used in place of a parameter type to indicate that the following sequence of parameters bind to variables in scope. >*/
+    (void) (add)( (double)(num) (const bind)((factor)) /*< The variable `factor` is bound by constant value so it cannot be mistakenly modified by the local function body. >*/ (bind)((&sum)) /*< The variable `sum` is instead bound by non-constant reference because the local function needs to change its value to report the summation result to the enclosing scope. >*/ )
+    ) { /*< The local function body is programmed using the usual C++ syntax. >*/
+        sum += factor * num;
+        std::clog << "Summed: " << sum << std::endl;
+    } BOOST_LOCAL_FUNCTION_END(add) /*< The macro ending the local function definition (note how the local function name needs to be repeated here). >*/
+    add(100.0); /*< The local function macros declare a functor object local to the enclosing scope named `add`. As indicated by the local function parenthesized signature, the functor `add` has `void` result type, it can be called by specifying one parameter of type `double`, and it has access to the variables in scope `factor` and `sum`. >*/
+
+    size_t size = 2;
+    double* nums = new double[size];
+    BOOST_LOCAL_EXIT( (const bind)((&size)) (bind)((nums)) ) { /*< The *local exit* declaration macro only specifies the variables in scope to bind (eventually as constants). >*/
+        if (size && nums) delete[] nums; /*< The local exit code will be automatically executed when the enclosing scope is exited. >*/
+        std::clog << "Freed array: " << nums << std::endl;
+    } BOOST_LOCAL_EXIT_END /*< A local exit is anonymous so its ending macro takes no argument. >*/
+
+    nums[0] = 90.5; nums[1] = 7.0;
+    std::for_each(nums, nums + size, add); /*< The local function `add` can also be passed as a template parameter to the STL `std::for_each` algorithm. >*/
+
+    BOOST_LOCAL_BLOCK( (const bind)((&sum)) ) { /*< The *local block* declaration macro only specifies the variables in scope to bind (eventually as constants). >*/ 
+        // So far: sum = 10 * 100.0 + 10 * 90.5 + 10 * 7.0 = 1975.0
+        assert(sum == 1975.0); /*< The local block code is executed "in place" where it is programmed like a usual C++ block of code `{ ... }`. In this example, the compiler will correctly generate an error if the assignment operator `=` is mistakenly used instead of the equality operator `==` because the variable `sum` is bound by constant reference so it cannot be modified. >*/
+        std::clog << "Asserted summation: " << sum << std::endl;
+    } BOOST_LOCAL_BLOCK_END /*< A local block is anonymous so its ending macro takes no argument. >*/
+    
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_block.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_block.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,29 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Simple local block used by the documentation.
+
+//[ add_block_cpp
+#include <boost/local/block.hpp>
+#include <iostream>
+#include <cassert>
+
+int main() {
+    double sum = 1975.0;
+
+    BOOST_LOCAL_BLOCK( (const bind)((&sum)) ) {
+        assert(sum == 1975.0); // OK: Complier error if `==` confused with `=`.
+        std::clog << "Asserted summation: " << sum << std::endl;
+
+        return; // Return this local block (and not the enclosing scope).
+        assert(false); // OK: Never executed.
+    } BOOST_LOCAL_BLOCK_END
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_except.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_except.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,47 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Use local functions, blocks, and exits from template scope.
+
+//[add_except_cpp
+#include <boost/local/function.hpp>
+#include <boost/local/block.hpp>
+#include <boost/local/exit.hpp>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+int main() {
+    double sum = 0.0;
+    int factor = 10;
+
+    BOOST_LOCAL_FUNCTION(
+    (void) (add)( (double)(num) (const bind)((factor)) (bind)((&sum)) )
+    ) throw (std::runtime_error, std::logic_error) { // Throw two exceptions.
+        sum += factor * num;
+    } BOOST_LOCAL_FUNCTION_END(add)
+    add(100.0);
+
+    size_t size = 2;
+    double* nums = new double[size];
+    // Throw nothing.
+    BOOST_LOCAL_EXIT( (const bind)((&size)) (bind)((nums)) ) throw() {
+        if (size && nums) delete[] nums;
+    } BOOST_LOCAL_EXIT_END
+
+    nums[0] = 90.5; nums[1] = 7.0;
+    std::for_each(nums, nums + size, add);
+
+    // Throw one exception.
+    BOOST_LOCAL_BLOCK( (const bind)((&sum)) ) throw(std::exception) {
+        assert(sum == 1975.0);
+    } BOOST_LOCAL_BLOCK_END
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_exit.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_exit.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,30 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Simple local exit used by the documentation.
+
+//[ add_exit_cpp
+#include <boost/local/exit.hpp>
+#include <iostream>
+#include <cassert>
+
+int main() {
+    size_t size = 2;
+    double* nums = new double[size];
+    
+    BOOST_LOCAL_EXIT( (const bind)((&size)) (bind)((nums)) ) {
+        if (size && nums) delete[] nums;
+        std::clog << "Freed array: " << nums << std::endl;
+
+        return; // Return this local exit (and not the enclosing scope).
+        assert(false); // OK: Never executed.
+    } BOOST_LOCAL_EXIT_END
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_num.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_num.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,26 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Simple parenthesized syntax example used by the documentation.
+
+//[ add_num_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+    BOOST_LOCAL_FUNCTION(
+    (void) (add)( (double)(num) )
+    ) {
+        std::clog << num << std::endl;
+    } BOOST_LOCAL_FUNCTION_END(add)
+
+    add(100.0);
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_num_factor_sum.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_num_factor_sum.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,30 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Simple parenthesized syntax example used by the documentation.
+
+//[ add_num_factor_sum_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+    double sum = 0.0;
+    int factor = 10;
+
+    BOOST_LOCAL_FUNCTION(
+    (void) (add)( (double)(num) (const bind)((factor)) (bind)((&sum)) )
+    ) {
+        sum += factor * num;
+        std::clog << "Summed: " << sum << std::endl;
+    } BOOST_LOCAL_FUNCTION_END(add)
+
+    add(100.0);
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_num_sum.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_num_sum.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,29 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Simple parenthesized syntax example used by the documentation.
+
+//[ add_num_sum_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+    double sum = 0.0;
+
+    BOOST_LOCAL_FUNCTION(
+    (void) (add)( (double)(num) (bind)((&sum)) )
+    ) {
+        sum += num;
+        std::clog << "Summed: " << sum << std::endl;
+    } BOOST_LOCAL_FUNCTION_END(add)
+
+    add(100.0);
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_optimizers.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_optimizers.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,29 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Show how to use some optimizations (inlining, auto, register, etc).
+
+//[add_optimizers_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+    BOOST_LOCAL_FUNCTION(
+    (inline) (int) (add)(           // Inlined local function.
+            (auto)(int)(x)          // Auto parameter.
+            (register)(int)(y)      // Register parameter.
+        )
+    ) {
+        return x + y;
+    } BOOST_LOCAL_FUNCTION_END(add)
+
+    std::cout << add(3, 5) << std::endl;
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_template.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_template.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,51 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Use local functions, blocks, and exits from template scope.
+
+//[add_template_cpp
+#include <boost/local/function.hpp>
+#include <boost/local/block.hpp>
+#include <boost/local/exit.hpp>
+#include <algorithm>
+#include <cassert>
+
+template<typename T>
+T total(const T& x, const T& y, const T& z) {
+    T sum = T();
+    int factor = 10;
+
+    BOOST_LOCAL_FUNCTION_TPL( // Use `..._TPL()` macros in templates.
+    (void) (add)( (T)(num) (const bind)((factor)) (bind)((&sum)) )
+    ) {
+        sum += factor * num;
+    } BOOST_LOCAL_FUNCTION_END(add)
+    add(x);
+
+    size_t size = 2;
+    T* nums = new T[size];
+    BOOST_LOCAL_EXIT_TPL( (const bind)((&size)) (bind)((nums)) ) {
+        if (size && nums) delete[] nums;
+    } BOOST_LOCAL_EXIT_END
+
+    nums[0] = y; nums[1] = z;
+    std::for_each(nums, nums + size, add);
+
+    BOOST_LOCAL_BLOCK_TPL(
+            (const bind)((&sum)(&factor)(&x)(&y)(&z)) ) {
+        assert(sum == factor * (x + y + z));
+    } BOOST_LOCAL_BLOCK_END
+
+    return sum;
+}
+
+int main() {
+    total(100.0, 90.5, 7.0);
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_this.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_this.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,49 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Simple parenthesized syntax example used by the documentation.
+
+//[ add_this_cpp
+#include <boost/local/function.hpp>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+#include <cassert>
+
+class adder {
+public:
+    adder(): sum_(0.0) {}
+
+    double sum(const std::vector<double>& nums, const int& factor = 10) {
+
+        BOOST_LOCAL_FUNCTION(
+        (void) (add)( (double)(num) (const bind)((factor)) (bind)((this)) )
+        ) {
+            this_->sum_ += factor * num; // Use `this_` instead of `this`.
+            std::clog << "Summed: " << this_->sum_ << std::endl;
+        } BOOST_LOCAL_FUNCTION_END(add)
+
+        std::for_each(nums.begin(), nums.end(), add);
+        return sum_;
+    }
+
+private:
+    double sum_;
+};
+
+int main() {
+    std::vector<double> v(3);
+    v[0] = 100.0; v[1] = 90.5; v[2] = 7.0;
+
+    adder a;
+    // sum = 10 * 100.0 + 10 * 90.5 + 10 * 7.0 = 1975.0
+    assert(a.sum(v) == 1975.0);
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/block.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/block.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,39 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Use of local code blocks (with const and non-const binding).
+
+#include <boost/local/block.hpp>
+#include <cassert>
+
+struct c {
+    c(): x_(0) {}
+
+    void f(int& x) { // Non-const member function so `this` is not const.
+        // Non-const `this` but const `x`.
+        BOOST_LOCAL_BLOCK( (const bind)((&x)) (bind)((this)) ) {
+            this_->x_ = x; // Non-const `this` cant be modified.
+            assert(x == this_->x_); // Compiler error if `=` instead of `==`.
+            
+            return; // Exit local block (not enclosing function).
+            assert(false); // Never executed.
+        } BOOST_LOCAL_BLOCK_END
+
+        x = x_; // Non-const `x` changed outside block.
+    }
+
+private:
+    int x_;
+};
+
+int main() {
+    c cc;
+    int x = 1;
+    cc.f(x);
+    return 0;
+}
+
Added: sandbox/local/libs/local/example/doit.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/doit.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,66 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Pass local function as a parameter.
+// Adapted from C++0x lambda papaer N2529 (added default parameters).
+
+//[ doit_cpp
+#include <boost/local/function_ref.hpp>
+#include <boost/local/function.hpp>
+#include <boost/function.hpp>
+#include <iostream>
+
+// Using `function_ref` allows to use the same functor for all calls
+// (regardless of which set of default parameters is specified).
+void doit(boost::local::function_ref< int (int, int), 2 > l) {
+    std::cout << l(1, 2) << std::endl;
+    std::cout << l(1) << std::endl;
+    std::cout << l() << std::endl;
+}
+
+// Using `function` requires different functors for calls with different set of
+// default parameters.
+void doit2(boost::function< int (int, int) > l)
+    { std::cout << l(1, 2) << std::endl; }
+void doit1(boost::function< int (int) > l) { std::cout << l(1) << std::endl; }
+void doit0(boost::function< int () > l) { std::cout << l() << std::endl; }
+
+int main() {
+    boost::function<int (int, int)> l2;
+
+    {
+        int i = 2;
+    
+        BOOST_LOCAL_FUNCTION(
+        (int) (linear)( (int)(x)(default)(1) (int)(y)(default)(2)
+                (bind)( (i) ) )
+        ) {
+            return x + i * y;
+        } BOOST_LOCAL_FUNCTION_END(linear)
+
+        // Assign local functions variables.
+        boost::local::function_ref< int (int, int), 2 > l = linear;
+        l(1, 2); l(1); l(); // All calls because of default parameters.
+        l2 = linear;
+        l2(1, 2); // Only one call operation (without default parameters).
+
+        // Similarly, pass local functions as a function parameter.
+        doit(linear);
+        std::cout << std::endl;
+        doit2(linear);
+        doit1(linear);
+        doit0(linear);
+    }
+        
+    if (false) {
+        l2(1, 2); // This wouuld raise run-time error because invalid reference.
+    }
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/exit.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/exit.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,110 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Use local scope exit (with const, non-const, and `this` binding).
+// Adapted from Boost.ScopeExit documentation.
+
+#include <boost/local/exit.hpp>
+#include <boost/foreach.hpp>
+#include <boost/typeof/std/vector.hpp> // Typeof emulation mode.
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() // Typeof emulation mode.
+#include <vector>
+#include <ostream>
+#include <iostream>
+#include <cassert>
+
+class world;
+
+class person {
+    friend class world;
+public:
+    typedef unsigned int id_t;
+    typedef unsigned int evolution_t;
+
+    person(): id_(0), evolution_(0) {}
+
+    friend std::ostream& operator<<(std::ostream& o, person const& p)
+        { return o << "person: " << p.id_ << ", " << p.evolution_; }
+
+private:
+    id_t id_;
+    evolution_t evolution_;
+};
+
+BOOST_TYPEOF_REGISTER_TYPE(person)
+
+class world {
+public:
+    typedef unsigned int id_t;
+
+    world(): next_id_(1) {}
+
+    void add_person(person const& a_person);
+
+    friend std::ostream& operator<<(std::ostream& o, world const& w) {
+        o << "world: " << w.next_id_ << ", {";
+        BOOST_FOREACH(person const& p, w.persons_) {
+            o << ' ' << p << ',';
+        }
+        return o << "}";
+    }
+private:
+    id_t next_id_;
+    std::vector<person> persons_;
+};
+
+BOOST_TYPEOF_REGISTER_TYPE(world)
+
+void world::add_person(person const& a_person) {
+    persons_.push_back(a_person);
+
+    // This block must be no-throw.
+    person& p = persons_.back();
+    person::evolution_t checkpoint = p.evolution_;
+
+    BOOST_LOCAL_EXIT(
+        (const bind)( (checkpoint) (&p) ) (bind)( (this) )
+    ) {
+        if (checkpoint == p.evolution_) this_->persons_.pop_back();
+        std::cout << "1st local exit" << std::endl;
+        return; // Exit local scope (not enclosing function).
+        assert(false);
+    } BOOST_LOCAL_EXIT_END
+
+    // ...
+
+    checkpoint = ++p.evolution_;
+
+    // Assign new id to the person.
+    world::id_t const prev_id = p.id_;
+    p.id_ = next_id_++;
+    BOOST_LOCAL_EXIT(
+        (const bind)( (checkpoint) (prev_id) ) (bind)( (&p) (&next_id_) )
+    ) {
+        if (checkpoint == p.evolution_) {
+            next_id_ = p.id_;
+            p.id_ = prev_id;
+        }
+        std::cout << "2nd local exit" << std::endl;
+    } BOOST_LOCAL_EXIT_END
+
+    // ...
+
+    checkpoint = ++p.evolution_;
+}
+
+int main() {
+    person adamo, eva;
+    std::cout << adamo << std::endl;
+    std::cout << eva << std::endl;
+
+    world w;
+    w.add_person(adamo);
+    w.add_person(eva);
+    std::cout << w << std::endl;
+}
+
Added: sandbox/local/libs/local/example/factorial.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/factorial.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,45 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Use recursion, default parameters, and bind by non-const reference.
+
+//[ factorial_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+#include <sstream>
+#include <algorithm>
+#include <vector>
+
+int main () {
+    std::vector<int> v;
+    v.resize(3);
+    v[0] = 1; v[1] = 4; v[2] = 7;
+    std::ostringstream factorials;
+
+    BOOST_LOCAL_FUNCTION(
+    (int) (factorial)(
+            (int)(n)
+            (bool)(recursion)(default)(false)
+            (bind)((&factorials))
+        )
+    ) {
+        int result = 0;
+
+        if (n < 2 ) result = 1;
+        else result = n * factorial(n - 1, true); // Recursive call.
+
+        if (!recursion) factorials << result << " ";
+        return result;
+    } BOOST_LOCAL_FUNCTION_END(factorial)
+
+    std::for_each(v.begin(), v.end(), factorial);
+    std::cout << factorials.str() << std::endl;
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/find_if.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/find_if.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,51 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Pass local function to STL algorithm.
+// Adapted from C++0x lambda paper N2550.
+
+#include <boost/local/function.hpp>
+#include <list>
+#include <algorithm>
+#include <iostream>
+
+class employee {
+public:
+    explicit employee(const double& salary): salary_(salary) {}
+    double salary() const { return salary_; }
+private:
+    double salary_;
+};
+
+int main() {
+    std::list<employee> employees;
+    employees.push_back(employee( 85000.00));
+    employees.push_back(employee(100000.00));
+    employees.push_back(employee(120000.00));
+
+    double min_salary = 100000.00;
+    double u_limit = 1.1 * min_salary;
+
+    BOOST_LOCAL_FUNCTION(
+    (bool) (between)(
+            (const employee&)(e)
+            (const bind)( (&min_salary) (&u_limit) )
+        )
+    ) {
+        return e.salary() >= min_salary && e.salary() < u_limit;
+    } BOOST_LOCAL_FUNCTION_END(between)
+    
+    // Pass local function to an STL algorithm as a template paramter (this
+    // cannot be done with plain member funcitons of local classes).
+    std::list<employee>::iterator i = std::find_if(
+            employees.begin(), employees.end(), between);
+
+    if (i != employees.end()) { std::cout << i->salary() << std::endl; }
+    
+    return 0;
+}
+
Added: sandbox/local/libs/local/example/jamfile.jam
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/jamfile.jam	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,31 @@
+
+# Copyright (C) 2009-2011 Lorenzo Caminiti
+# Use, modification, and distribution is subject to the
+# Boost Software License, Version 1.0
+# (see accompanying file LICENSE_1_0.txt or a copy at
+# http://www.boost.org/LICENSE_1_0.txt).
+
+exe add : add.cpp ;
+exe add_block : add_block.cpp ;
+exe add_except : add_except.cpp ;
+exe add_exit : add_exit.cpp ;
+exe add_num : add_num.cpp ;
+exe add_num_factor_sum : add_num_factor_sum.cpp ;
+exe add_num_sum : add_num_sum.cpp ;
+exe add_optimizers : add_optimizers.cpp ;
+exe add_template : add_template.cpp ;
+exe add_this : add_this.cpp ;
+
+exe block : block.cpp ;
+exe doit : doit.cpp ;
+exe exit : exit.cpp ;
+exe factorial : factorial.cpp ;
+exe find_if : find_if.cpp ;
+exe params : params.cpp ;
+exe print_map : print_map.cpp ;
+exe renamed_exit : renamed_exit.cpp ;
+exe renamed_print : renamed_print.cpp ;
+exe this : this.cpp ;
+exe transform : transform.cpp ;
+exe same_line : same_line.cpp ;
+
Added: sandbox/local/libs/local/example/params.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/params.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,189 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Use all different parameter and binding permutations.
+
+#include <boost/local/function.hpp>
+
+struct c {
+    void f(double p = 1.23, double q = -1.23) {
+        { // No params, no const binds, no plain binds.
+            BOOST_LOCAL_FUNCTION(
+            (void) (l)( (void) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(l)
+            l();
+        }
+
+        { // Only params.
+            BOOST_LOCAL_FUNCTION(
+            (void) (l)( (int)(x) (int)(y)(default)(0) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(l)
+            l(1);
+        }
+        { // Only const binds.
+            int a, b;
+            BOOST_LOCAL_FUNCTION(
+            (void) (l)( (const bind)((a)(&b)(&p)(q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(l)
+            l();
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (t)( (const bind)((this)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(t)
+            t();
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (lt)( (const bind)((a)(&b)(&p)(q)(this)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(lt)
+            lt();
+        }
+        { // Only plain binds.
+            int c, d;
+            BOOST_LOCAL_FUNCTION(
+            (void) (l)( (bind)((c)(&d)(&p)(&q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(l)
+            l();
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (t)( (bind)((this)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(t)
+            t();
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (lt)( (bind)((c)(&d)(&p)(&q)(this)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(lt)
+            lt();
+        }
+
+        { // Both params and const binds.
+            int a, b;
+            BOOST_LOCAL_FUNCTION(
+            (void) (l)( (int)(x) (int)(y)(default)(0)
+                    (const bind)((a)(&b)(&p)(q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(l)
+            l(1);
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (t)( (int)(x) (int)(y)(default)(0)
+                    (const bind)((this)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(t)
+            t(1);
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (lt)( (int)(x) (int)(y)(default)(0)
+                    (const bind)((a)(this)(&b)(&p)(q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(lt)
+            lt(1);
+        }
+        { // Both params and plain binds.
+            int c, d;
+            BOOST_LOCAL_FUNCTION(
+            (void) (l)( (int)(x) (int)(y)(default)(0)
+                    (bind)((c)(&d)(&p)(q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(l)
+            l(1);
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (t)( (int)(x) (int)(y)(default)(0)
+                    (bind)((this)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(t)
+            t(1);
+            
+            BOOST_LOCAL_FUNCTION(
+            (void) (lt)( (int)(x) (int)(y)(default)(0)
+                    (bind)((c)(&d)(&p)(this)(q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(lt)
+            lt(1);
+        }
+        { // Both const and plain binds.
+            int a, b, c, d;
+            BOOST_LOCAL_FUNCTION(
+            (void) (l)( (const bind)((a)(&b)(p)) (bind)((c)(&d)(q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(l)
+            l();
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (ct)( (const bind)((this)) (bind)((c)(&d)(q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(ct)
+            ct();
+            BOOST_LOCAL_FUNCTION(
+            (void) (lct)( (const bind)((this)(a)(&b)(p)) (bind)((c)(&d)(q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(lct)
+            lct();
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (pt)( (const bind)((a)(&b)(p)) (bind)((this)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(pt)
+            pt();
+            BOOST_LOCAL_FUNCTION(
+            (void) (lpt)( (const bind)((a)(&b)(p)) (bind)((c)(this)(&d)(q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(lpt)
+            lpt();
+        }
+
+        { // All params, const binds, and plain binds.
+            int a, b, c, d;
+            BOOST_LOCAL_FUNCTION(
+            (void) (l)( (int)(x) (int)(y)(default)(0)
+                    (const bind)((a)(&b)(&p)) (bind)((c)(&d)(&q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(l)
+            l(1);
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (ct)( (int)(x) (int)(y)(default)(0)
+                    (const bind)((this)) (bind)((c)(&d)(&q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(ct)
+            ct(1);
+            BOOST_LOCAL_FUNCTION(
+            (void) (pt)( (int)(x) (int)(y)(default)(0)
+                    (const bind)((a)(&b)(&p)) (bind)((this)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(pt)
+            pt(1);
+
+            BOOST_LOCAL_FUNCTION(
+            (void) (lct)( (int)(x) (int)(y)(default)(0)
+                    (const bind)((a)(this)(&b)(&p)) (bind)((c)(&d)(&q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(lct)
+            lct(1);
+            BOOST_LOCAL_FUNCTION(
+            (void) (lpt)( (int)(x) (int)(y)(default)(0)
+                    (const bind)((a)(&b)(&p)) (bind)((c)(&d)(this)(&q)) )
+            ) {
+            } BOOST_LOCAL_FUNCTION_END(lpt)
+            lpt(1);
+        }
+    }
+};
+    
+int main() {
+    c().f();
+    return 0;
+}
+
Added: sandbox/local/libs/local/example/print_map.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/print_map.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,51 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Show how to handle commas and symbols in macro parameters.
+
+//[ print_map_cpp
+#include <boost/local/function.hpp>
+#include <boost/utility/identity.hpp>
+#include <map>
+#include <string>
+#include <iostream>
+
+template<typename K, typename T> struct key_size { static const size_t value; };
+template<typename K, typename T> const size_t key_size<K, T>::value = sizeof(K);
+
+std::string cat(const std::string& a, const std::string& b) { return a + b; }
+
+typedef int const& sign_t;
+
+int main() {
+    BOOST_LOCAL_FUNCTION(
+    (void) (print)(
+            // Identity macors handle commas.
+            (BOOST_IDENTITY_TYPE((const std::map<std::string, size_t>&)))(m)
+            (const size_t&)(factor)(default)
+                    (BOOST_IDENTITY_VALUE((key_size<std::string, size_t>::value)))
+            (const std::string&)(separator)(default)(cat(":", " "))
+            // Also, identity macors handle leading symbols.
+            (BOOST_IDENTITY_TYPE((::sign_t)))(sign)(default)
+                    (BOOST_IDENTITY_VALUE((-1)))
+        )
+    ) {
+        for (std::map<std::string, size_t>::const_iterator i = m.begin();
+                i != m.end(); ++i) {
+            std::cout << i->first << separator <<
+                    sign * int(i->second) * int(factor) << std::endl;
+        }
+    } BOOST_LOCAL_FUNCTION_END(print)
+
+    std::map<std::string, size_t> sizes;
+    sizes["a"] = 1; sizes["ab"] = 2; sizes["abc"] = 3;
+    print(sizes);
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/renamed_exit.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/renamed_exit.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,48 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Implement simple local exit using local function renaming.
+
+//[ renamed_exit_cpp
+#include <boost/local/function.hpp>
+#include <boost/local/function_ref.hpp>
+#include <boost/preprocessor/cat.hpp>
+
+#define EXIT(parenthesized_binding) \
+    BOOST_LOCAL_FUNCTION( \
+    (void) (BOOST_PP_CAT(exit_code, __LINE__))( parenthesized_binding ) \
+    ) /* followed by exit body here */
+
+// Local function renaming is necessary because `__LINE__` has a different
+// value when `EXIT_END` macro expands respect to its value when the `EXIT()`
+// macro expands.
+#define EXIT_END \
+    /* preceded by exit body here */ \
+    BOOST_LOCAL_FUNCTION_END_RENAME( \
+            BOOST_PP_CAT(exit_code, __LINE__)) \
+    exit_guard BOOST_PP_CAT(exit_guardian, __LINE__)( \
+            BOOST_PP_CAT(exit_code, __LINE__));
+
+struct exit_guard {
+    typedef boost::local::function_ref< void () > ref_type;
+    explicit exit_guard(ref_type ref): ref_(ref) {}
+    ~exit_guard() { ref_(); } // Execute local function code at scope exit.
+private:
+    ref_type ref_;
+};
+
+int main() {
+    int* a = new int[3];
+    EXIT( (bind)((a)) ) {
+        // Body outside macros so retain complier error meaning.
+        if (a) delete[] a;
+    } EXIT_END
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/renamed_print.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/renamed_print.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,35 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Show who to rename a local function and pass it as template parameter.
+
+//[ renamed_print_cpp
+#include <boost/local/function.hpp>
+#include <boost/local/function_ref.hpp>
+#include <algorithm>
+#include <iostream>
+
+int main() {
+    BOOST_LOCAL_FUNCTION(
+    (void) (print)( (int)(x) )
+    ) {
+        // Only original `print` name available within local function body.
+        std::cout << x << std::endl;
+    } BOOST_LOCAL_FUNCTION_END_RENAME(new_print)
+    // Only new `new_print` name available within enclosing scope.
+
+    int a[3] = {1, 2, 3};
+
+    // std::for_each(a, a + 3, new_print); // Error: Passing renamed function.
+
+    boost::local::function_ref< void (int) > print_ref = new_print;
+    std::for_each(a, a + 3, print_ref); // OK: Passing function reference.
+
+    return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/same_line.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/same_line.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,21 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Show that local functions can be defined on the same line of code.
+
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+    BOOST_LOCAL_FUNCTION( (void) (l)( (int)(x) ) ) { std::cout << x << std::endl; } BOOST_LOCAL_FUNCTION_END(l) BOOST_LOCAL_FUNCTION( (void) (m)( (int)(x) ) ) { std::cout << x << std::endl; } BOOST_LOCAL_FUNCTION_END(m)
+    
+    l(1);
+    m(2);
+
+    return 0;
+}
+
Added: sandbox/local/libs/local/example/this.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/this.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,55 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Bind non-const object `this`.
+// Adapted from C++0x lambda paper N2529.
+
+#include <boost/local/function.hpp>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+
+class a {
+public:
+    a(const std::vector<double>& numbers): v_(numbers) {}
+
+    void change_sign_all(const std::vector<int>& indices) {
+        BOOST_LOCAL_FUNCTION(
+        (void) (complement)( (int)(i) (bind)( (this) ) ) // Bind object `this`.
+        ) {
+            // Local function uses special name `this_` to access bound object.
+            this_->v_[i] = -this_->v_[i];
+        } BOOST_LOCAL_FUNCTION_END(complement)
+        std::for_each(indices.begin(), indices.end(), complement);
+    }
+
+    friend std::ostream& operator<<(std::ostream& s, const a& obj) {
+        for (std::vector<double>::const_iterator i = obj.v_.begin();
+                i != obj.v_.end(); ++i) {
+            s << *i << " ";
+        }
+        return s;
+    }
+
+private:
+    std::vector<double> v_;
+};
+
+int main() {
+    std::vector<double> n(3, 0);
+    n[0] = 1.11; n[1] = 2.22; n[2] = 3.33;
+
+    std::vector<int> i(2, 0);
+    i[0] = 0; i[1] = 2;
+    
+    a an(n);
+    an.change_sign_all(i);
+    std::cout << an << std::endl;
+    
+    return 0;
+}
+
Added: sandbox/local/libs/local/example/transform.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/transform.cpp	2011-01-10 16:12:31 EST (Mon, 10 Jan 2011)
@@ -0,0 +1,53 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+// Bind another local function.
+
+#include <boost/local/function.hpp>
+#include <iostream>
+#include <algorithm>
+#include <vector>
+
+int main () {
+    int offset = 5;
+    std::vector<int> v;
+    std::vector<int> w;
+
+    // v = 10 20 30 40 50
+    for (int i = 1; i < 6; i++) v.push_back(i * 10);
+    w.resize(v.size());
+
+    // w = ++v + 5 = 16 26 36 46 56
+    BOOST_LOCAL_FUNCTION(
+    (int) (inc)( (int)(i) (const bind)( (&offset) ) )
+    ) {
+        // Compiler error if const `offset` modified here by mistake.
+        return ++i + offset;
+    } BOOST_LOCAL_FUNCTION_END(inc)
+    std::transform(v.begin(), v.end(), w.begin(), inc);
+
+    offset = 0;
+
+    // v = ++(v + w) + 0 = 27 47 67 87 107
+    BOOST_LOCAL_FUNCTION(
+    (int) (inc_sum)(
+            (int)(i)
+            (int)(j)
+            (bind)( (inc) ) // Bind another local function.
+        )
+    ) {
+        return inc(i + j); // Call the bound local function.
+    } BOOST_LOCAL_FUNCTION_END(inc_sum)
+    std::transform(v.begin(), v.end(), w.begin(), v.begin(), inc_sum);
+
+    for (std::vector<int>::iterator i = v.begin(); i != v.end(); ++i)
+        { std::cout << " " << *i; }
+    std::cout << std::endl;
+    
+    return 0;
+}
+