gcc_lambda.cpp 861 B

123456789101112131415161718192021222324252627282930313233343536
  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. #ifndef __GNUC__
  8. # error "GCC required (using non-standard GCC statement expressions)"
  9. #else
  10. #include "gcc_lambda.hpp"
  11. #include <boost/detail/lightweight_test.hpp>
  12. #include <algorithm>
  13. int main(void) {
  14. //[gcc_lambda
  15. int val = 2;
  16. int nums[] = {1, 2, 3};
  17. int* end = nums + 3;
  18. int* iter = std::find_if(nums, end,
  19. GCC_LAMBDA(const bind val, int num, return bool) {
  20. return num == val;
  21. } GCC_LAMBDA_END
  22. );
  23. //]
  24. BOOST_TEST(iter != end);
  25. BOOST_TEST(*iter == val);
  26. return boost::report_errors();
  27. }
  28. #endif // GCC