summaryrefslogtreecommitdiff
path: root/libs/local_function/test/return_inc_seq.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/local_function/test/return_inc_seq.cpp')
-rw-r--r--libs/local_function/test/return_inc_seq.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/libs/local_function/test/return_inc_seq.cpp b/libs/local_function/test/return_inc_seq.cpp
new file mode 100644
index 0000000000..6116ea990d
--- /dev/null
+++ b/libs/local_function/test/return_inc_seq.cpp
@@ -0,0 +1,31 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::function<int (void)> inc(int& value) {
+ int BOOST_LOCAL_FUNCTION( (bind& value) ) {
+ return ++value;
+ } BOOST_LOCAL_FUNCTION_NAME(i)
+ return i;
+}
+
+int main(void) {
+ int value1 = 0;
+ boost::function<int (void)> inc1 = inc(value1);
+ int value2 = 0;
+ boost::function<int (void)> inc2 = inc(value2);
+
+ BOOST_TEST(inc1() == 1);
+ BOOST_TEST(inc1() == 2);
+ BOOST_TEST(inc2() == 1);
+ BOOST_TEST(inc1() == 3);
+ return boost::report_errors();
+}
+