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#include <vector>
11#include <algorithm>
12
13int main(void) {
14 int sum = 0, factor = 10;
15
16 void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) {
17 sum += factor * num;
18 } BOOST_LOCAL_FUNCTION_NAME(inline add)
19
20 std::vector<int> v(100);
21 std::fill(first: v.begin(), last: v.end(), value: 1);
22
23 for(size_t i = 0; i < v.size(); ++i) add(v[i]);
24
25 BOOST_TEST(sum == 1000);
26 return boost::report_errors();
27}
28
29

source code of boost/libs/local_function/test/add_inline_seq.cpp