1 | |
---|---|
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 |
7 | |
8 | #include <boost/local_function.hpp> |
9 | #include <boost/detail/lightweight_test.hpp> |
10 | |
11 | int main(void) { |
12 | double sum = 0.0; |
13 | int factor = 10; |
14 | |
15 | void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) |
16 | (double num) ) throw() { |
17 | sum += factor * num; |
18 | } BOOST_LOCAL_FUNCTION_NAME(add) |
19 | |
20 | add(100); |
21 | |
22 | BOOST_TEST(sum == 1000); |
23 | return boost::report_errors(); |
24 | } |
25 | |
26 |