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/config.hpp> 9 #ifdef BOOST_NO_CXX11_VARIADIC_MACROS 10 # error "variadic macros required" 11 #else 12 13 #include <boost/local_function.hpp> 14 #include <boost/detail/lightweight_test.hpp> 15 main(void)16int main(void) { 17 //[add_except 18 double sum = 0.0; 19 int factor = 10; 20 21 void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum, 22 double num) throw() { // Throw nothing. 23 sum += factor * num; 24 } BOOST_LOCAL_FUNCTION_NAME(add) 25 26 add(100); 27 //] 28 29 BOOST_TEST(sum == 1000); 30 return boost::report_errors(); 31 } 32 33 #endif // VARIADIC_MACROS 34 35