]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/lambda/test/bll_and_function.cpp
1 // bll_and_function.cpp - The Boost Lambda Library -----------------------
3 // Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
4 // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 // For more information, see www.boost.org
12 // test using BLL and boost::function
14 #include <boost/test/minimal.hpp> // see "Header Implementation Option"
16 #include "boost/lambda/lambda.hpp"
18 #include "boost/function.hpp"
26 using namespace boost::lambda
;
30 void test_function() {
32 boost::function
<int (int, int)> f
;
35 BOOST_CHECK(f(1, 2)== 3);
38 boost::function
<int& (int&, int)> g
= _1
+= _2
;
46 boost::function
<int& (int)> counter
= *sum
+= _1
;
47 counter(5); // ok, sum* = 5;
48 BOOST_CHECK(*sum
== 5);
51 // The next statement would lead to a dangling reference
52 // counter(3); // error, *sum does not exist anymore
57 int test_main(int, char *[]) {