2 // Copyright (C) 2009-2012 Lorenzo Caminiti
3 // Distributed under the Boost Software License, Version 1.0
4 // (see accompanying file LICENSE_1_0.txt or a copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 // Home at http://www.boost.org/libs/local_function
8 #include <boost/config.hpp>
9 #ifdef BOOST_NO_VARIADIC_MACROS
10 # error "variadic macros required"
13 #include <boost/local_function.hpp>
14 #include <boost/detail/lightweight_test.hpp>
18 int main(void) { // Some local scope.
19 int sum = 0, factor = 10; // Variables in scope to bind.
21 void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum, int num) {
23 } BOOST_LOCAL_FUNCTION_NAME(add)
25 add(1); // Call the local function.
27 std::for_each(nums, nums + 2, add); // Pass it to an algorithm.
29 BOOST_TEST(sum == 60); // Assert final summation value.
30 return boost::report_errors();
34 #endif // VARIADIC_MACROS