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 main(void)11int main(void) { 12 int nums[] = {1, 2, 3}; 13 int offset = -1; 14 int BOOST_LOCAL_FUNCTION(const bind offset, int* array, int index) { 15 return array[index + offset]; 16 } BOOST_LOCAL_FUNCTION_NAME(access) 17 18 BOOST_TEST(access(nums, 1) == 1); 19 BOOST_TEST(access(nums, 2) == 2); 20 BOOST_TEST(access(nums, 3) == 3); 21 return boost::report_errors(); 22 } 23 24