1 2 // Copyright (C) 2009-2012 Lorenzo Caminiti 3 // Distributed under the Boost Software License, Version 1.0 4 // (see accompanying file LICENSE_1_0.txt or a copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 // Home at http://www.boost.org/libs/local_function 7 8 #include <boost/config.hpp> 9 #ifdef BOOST_NO_CXX11_LAMBDAS 10 # error "requires lambda functions" 11 #else 12 13 #include <cassert> 14 main(void)15int main(void) { 16 //[const_block_cxx11_lambda 17 int x = 1, y = 2; 18 const decltype(x)& const_x = x; // Constant so cannot be modified 19 const decltype(y)& const_y = y; // and reference so no copy. 20 [&const_x, &const_y]() { // Lambda functions (C++11 only). 21 assert(const_x = const_y); // Unfortunately, `const_` names. 22 }(); 23 //] 24 return 0; 25 } 26 27 #endif // LAMBDAS 28 29