nesting.cpp 853 B

12345678910111213141516171819202122232425262728293031323334353637
  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/config.hpp>
  7. #ifdef BOOST_NO_CXX11_VARIADIC_MACROS
  8. # error "variadic macros required"
  9. #else
  10. #include <boost/local_function.hpp>
  11. #include <boost/detail/lightweight_test.hpp>
  12. int main(void) {
  13. //[nesting
  14. int x = 0;
  15. void BOOST_LOCAL_FUNCTION(bind& x) {
  16. void BOOST_LOCAL_FUNCTION(bind& x) { // Nested.
  17. x++;
  18. } BOOST_LOCAL_FUNCTION_NAME(g)
  19. x--;
  20. g(); // Nested local function call.
  21. } BOOST_LOCAL_FUNCTION_NAME(f)
  22. f();
  23. //]
  24. BOOST_TEST(x == 0);
  25. return boost::report_errors();
  26. }
  27. #endif // VARIADIC_MACROS