add_with_default.cpp 784 B

1234567891011121314151617181920212223242526272829303132
  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. //[add_with_default_macro
  13. #define WITH_DEFAULT , default
  14. //]
  15. int main(void) {
  16. //[add_with_default
  17. int BOOST_LOCAL_FUNCTION(int x, int y WITH_DEFAULT 2) { // Default.
  18. return x + y;
  19. } BOOST_LOCAL_FUNCTION_NAME(add)
  20. BOOST_TEST(add(1) == 3);
  21. //]
  22. return boost::report_errors();
  23. }
  24. #endif // VARIADIC_MACROS