gcc_square.cpp 601 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 add_square(int a, int b) {
  9. int BOOST_LOCAL_FUNCTION(int z) {
  10. return z * z;
  11. } BOOST_LOCAL_FUNCTION_NAME(square)
  12. return square(a) + square(b);
  13. }
  14. int main(void) {
  15. BOOST_TEST(add_square(2, 4) == 20);
  16. return boost::report_errors();
  17. }