noncopyable_cxx11_lambda_error.cpp 735 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. #ifdef BOOST_NO_CXX11_LAMBDAS
  8. # error "lambda functions required"
  9. #else
  10. #include <boost/noncopyable.hpp>
  11. #include <cassert>
  12. //[noncopyable_cxx11_lambda_error
  13. struct n: boost::noncopyable {
  14. int i;
  15. n(int _i): i(_i) {}
  16. };
  17. int main(void) {
  18. n x(-1);
  19. auto f = [x](void) { // Error: x is non-copyable, but if
  20. assert(x.i == -1); // bind `&x` then `x` is not constant.
  21. };
  22. f();
  23. return 0;
  24. }
  25. //]
  26. #endif // LAMBDAS