gcc_access.cpp 707 B

1234567891011121314151617181920212223
  1. // Copyright (C) 2009-2012 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0
  3. // (see accompanying file LICENSE_1_0.txt or a copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Home at http://www.boost.org/libs/local_function
  6. #include <boost/local_function.hpp>
  7. #include <boost/detail/lightweight_test.hpp>
  8. int main(void) {
  9. int nums[] = {1, 2, 3};
  10. int offset = -1;
  11. int BOOST_LOCAL_FUNCTION(const bind offset, int* array, int index) {
  12. return array[index + offset];
  13. } BOOST_LOCAL_FUNCTION_NAME(access)
  14. BOOST_TEST(access(nums, 1) == 1);
  15. BOOST_TEST(access(nums, 2) == 2);
  16. BOOST_TEST(access(nums, 3) == 3);
  17. return boost::report_errors();
  18. }