• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/local_function.hpp>
9 #include <boost/noncopyable.hpp>
10 #include <boost/typeof/typeof.hpp>
11 #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
12 #include <cassert>
13 
14 //[noncopyable_local_function
15 struct n: boost::noncopyable {
16     int i;
nn17     n(int _i): i(_i) {}
18 };
BOOST_TYPEOF_REGISTER_TYPE(n)19 BOOST_TYPEOF_REGISTER_TYPE(n) // Register for `bind& x` below.
20 
21 int main(void) {
22     n x(-1);
23 
24     void BOOST_LOCAL_FUNCTION(const bind& x) {  // OK: No copy
25         assert(x.i == -1);                      // and constant.
26     } BOOST_LOCAL_FUNCTION_NAME(f)
27     f();
28 
29     return 0;
30 }
31 //]
32 
33