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 "addable.hpp" |
9 | #include <boost/local_function.hpp> |
10 | #include <boost/type_traits/remove_reference.hpp> |
11 | #include <boost/concept_check.hpp> |
12 | #include <boost/detail/lightweight_test.hpp> |
13 | #include <algorithm> |
14 | |
15 | int main(void) { |
16 | int sum = 0, factor = 10; |
17 | |
18 | void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) { |
19 | BOOST_CONCEPT_ASSERT((Addable<boost::remove_reference< |
20 | BOOST_LOCAL_FUNCTION_TYPEOF(sum)>::type>)); |
21 | boost::remove_reference<BOOST_LOCAL_FUNCTION_TYPEOF( |
22 | factor)>::type mult = factor * num; |
23 | sum += mult; |
24 | } BOOST_LOCAL_FUNCTION_NAME(add) |
25 | |
26 | add(6); |
27 | BOOST_TEST(sum == 60); |
28 | return boost::report_errors(); |
29 | } |
30 | |
31 |