summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/local_function/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/local_function/test
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/local_function/test')
-rw-r--r--src/boost/libs/local_function/test/Jamfile.v251
-rw-r--r--src/boost/libs/local_function/test/add.cpp35
-rw-r--r--src/boost/libs/local_function/test/add_classifiers.cpp30
-rw-r--r--src/boost/libs/local_function/test/add_classifiers_seq.cpp26
-rw-r--r--src/boost/libs/local_function/test/add_classifiers_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/add_default.cpp28
-rw-r--r--src/boost/libs/local_function/test/add_default_seq.cpp19
-rw-r--r--src/boost/libs/local_function/test/add_default_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/add_except.cpp34
-rw-r--r--src/boost/libs/local_function/test/add_except_seq.cpp25
-rw-r--r--src/boost/libs/local_function/test/add_except_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/add_inline.cpp37
-rw-r--r--src/boost/libs/local_function/test/add_inline_seq.cpp28
-rw-r--r--src/boost/libs/local_function/test/add_inline_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/add_params_only.cpp28
-rw-r--r--src/boost/libs/local_function/test/add_params_only_seq.cpp19
-rw-r--r--src/boost/libs/local_function/test/add_params_only_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/add_seq.cpp28
-rw-r--r--src/boost/libs/local_function/test/add_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/add_template.cpp41
-rw-r--r--src/boost/libs/local_function/test/add_template_seq.cpp31
-rw-r--r--src/boost/libs/local_function/test/add_template_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/add_this.cpp51
-rw-r--r--src/boost/libs/local_function/test/add_this_seq.cpp43
-rw-r--r--src/boost/libs/local_function/test/add_this_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/add_typed.cpp47
-rw-r--r--src/boost/libs/local_function/test/add_typed_seq.cpp37
-rw-r--r--src/boost/libs/local_function/test/add_typed_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/add_with_default.cpp32
-rw-r--r--src/boost/libs/local_function/test/add_with_default_seq.cpp21
-rw-r--r--src/boost/libs/local_function/test/add_with_default_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/addable.hpp26
-rw-r--r--src/boost/libs/local_function/test/all_decl.cpp177
-rw-r--r--src/boost/libs/local_function/test/all_decl_seq.cpp170
-rw-r--r--src/boost/libs/local_function/test/all_decl_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/factorial.cpp57
-rw-r--r--src/boost/libs/local_function/test/factorial_seq.cpp48
-rw-r--r--src/boost/libs/local_function/test/factorial_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/goto.cpp34
-rw-r--r--src/boost/libs/local_function/test/goto_error.cpp36
-rw-r--r--src/boost/libs/local_function/test/goto_error_seq.cpp27
-rw-r--r--src/boost/libs/local_function/test/goto_error_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/goto_seq.cpp25
-rw-r--r--src/boost/libs/local_function/test/goto_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/macro_commas.cpp52
-rw-r--r--src/boost/libs/local_function/test/macro_commas_seq.cpp44
-rw-r--r--src/boost/libs/local_function/test/macro_commas_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/nesting.cpp37
-rw-r--r--src/boost/libs/local_function/test/nesting_seq.cpp28
-rw-r--r--src/boost/libs/local_function/test/nesting_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/nova.hpp21
-rw-r--r--src/boost/libs/local_function/test/operator.cpp38
-rw-r--r--src/boost/libs/local_function/test/operator_error.cpp38
-rw-r--r--src/boost/libs/local_function/test/operator_error_seq.cpp29
-rw-r--r--src/boost/libs/local_function/test/operator_error_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/operator_seq.cpp29
-rw-r--r--src/boost/libs/local_function/test/operator_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/overload.cpp52
-rw-r--r--src/boost/libs/local_function/test/overload_seq.cpp42
-rw-r--r--src/boost/libs/local_function/test/overload_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/return_assign.cpp49
-rw-r--r--src/boost/libs/local_function/test/return_assign_seq.cpp40
-rw-r--r--src/boost/libs/local_function/test/return_assign_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/return_derivative.cpp41
-rw-r--r--src/boost/libs/local_function/test/return_derivative_seq.cpp34
-rw-r--r--src/boost/libs/local_function/test/return_derivative_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/return_inc.cpp38
-rw-r--r--src/boost/libs/local_function/test/return_inc_seq.cpp31
-rw-r--r--src/boost/libs/local_function/test/return_inc_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/return_setget.cpp47
-rw-r--r--src/boost/libs/local_function/test/return_setget_seq.cpp39
-rw-r--r--src/boost/libs/local_function/test/return_setget_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/return_this.cpp50
-rw-r--r--src/boost/libs/local_function/test/return_this_seq.cpp43
-rw-r--r--src/boost/libs/local_function/test/return_this_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/same_line.cpp57
-rw-r--r--src/boost/libs/local_function/test/same_line_seq.cpp48
-rw-r--r--src/boost/libs/local_function/test/same_line_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/ten_void.cpp21
-rw-r--r--src/boost/libs/local_function/test/ten_void_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/transform.cpp47
-rw-r--r--src/boost/libs/local_function/test/transform_seq.cpp39
-rw-r--r--src/boost/libs/local_function/test/transform_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/typeof.cpp41
-rw-r--r--src/boost/libs/local_function/test/typeof_seq.cpp30
-rw-r--r--src/boost/libs/local_function/test/typeof_seq_nova.cpp10
-rw-r--r--src/boost/libs/local_function/test/typeof_template.cpp43
-rw-r--r--src/boost/libs/local_function/test/typeof_template_seq.cpp33
-rw-r--r--src/boost/libs/local_function/test/typeof_template_seq_nova.cpp10
89 files changed, 2762 insertions, 0 deletions
diff --git a/src/boost/libs/local_function/test/Jamfile.v2 b/src/boost/libs/local_function/test/Jamfile.v2
new file mode 100644
index 000000000..a12f5c340
--- /dev/null
+++ b/src/boost/libs/local_function/test/Jamfile.v2
@@ -0,0 +1,51 @@
+
+# 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
+
+import testing ;
+
+# Sun does not automatically detect type-of emulation mode (force it).
+project : requirements <toolset>sun:<define>BOOST_TYPEOF_EMULATION ;
+
+rule vaseq ( command target )
+{
+ $(command) $(target).cpp ;
+ $(command) $(target)_seq.cpp ;
+ $(command) $(target)_seq_nova.cpp ;
+}
+
+vaseq run add ;
+vaseq run add_classifiers ;
+vaseq run add_default ;
+vaseq run add_except ;
+vaseq run add_inline ;
+vaseq run add_params_only ;
+vaseq run add_template ;
+vaseq run add_this ;
+vaseq run add_typed ;
+vaseq run add_with_default ;
+vaseq run all_decl ;
+vaseq run factorial ;
+vaseq run goto ;
+vaseq compile-fail goto_error ;
+vaseq run macro_commas ;
+vaseq run nesting ;
+vaseq run operator ;
+vaseq compile-fail operator_error ;
+vaseq run overload ;
+vaseq run return_assign ;
+vaseq run return_derivative ;
+vaseq run return_inc ;
+vaseq run return_setget ;
+vaseq run return_this ;
+vaseq run same_line ;
+vaseq run transform ;
+vaseq run typeof ;
+vaseq run typeof_template ;
+
+run ten_void.cpp ;
+run ten_void_nova.cpp ;
+
diff --git a/src/boost/libs/local_function/test/add.cpp b/src/boost/libs/local_function/test/add.cpp
new file mode 100644
index 000000000..4b8ca3f1b
--- /dev/null
+++ b/src/boost/libs/local_function/test/add.cpp
@@ -0,0 +1,35 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+//[add
+int main(void) { // Some local scope.
+ int sum = 0, factor = 10; // Variables in scope to bind.
+
+ void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum, int num) {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(1); // Call the local function.
+ int nums[] = {2, 3};
+ std::for_each(nums, nums + 2, add); // Pass it to an algorithm.
+
+ BOOST_TEST(sum == 60); // Assert final summation value.
+ return boost::report_errors();
+}
+//]
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/add_classifiers.cpp b/src/boost/libs/local_function/test/add_classifiers.cpp
new file mode 100644
index 000000000..7dcf2dc04
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_classifiers.cpp
@@ -0,0 +1,30 @@
+
+// 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/config.hpp>
+#if !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
+# error "auto-declarations not allowed (using `auto` as storage classifier)"
+#elif defined(BOOST_NO_CXX11_VARIADIC_MACROS)
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[add_classifiers
+ int BOOST_LOCAL_FUNCTION(auto int x, register int y) { // Classifiers.
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+ //]
+
+ BOOST_TEST(add(1, 2) == 3);
+ return boost::report_errors();
+}
+
+#endif // AUTO_DECLARATIONS && VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/add_classifiers_seq.cpp b/src/boost/libs/local_function/test/add_classifiers_seq.cpp
new file mode 100644
index 000000000..0499f875c
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_classifiers_seq.cpp
@@ -0,0 +1,26 @@
+
+// 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/config.hpp>
+#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
+# error "auto-declarations not allowed (using `auto` as storage classifier)"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION( (auto int x) (register int y) ) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1, 2) == 3);
+ return boost::report_errors();
+}
+
+#endif // AUTO_DECLARATIONS
+
diff --git a/src/boost/libs/local_function/test/add_classifiers_seq_nova.cpp b/src/boost/libs/local_function/test/add_classifiers_seq_nova.cpp
new file mode 100644
index 000000000..346258468
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_classifiers_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "add_classifiers_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/add_default.cpp b/src/boost/libs/local_function/test/add_default.cpp
new file mode 100644
index 000000000..86c4e115a
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_default.cpp
@@ -0,0 +1,28 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[add_default
+ int BOOST_LOCAL_FUNCTION(int x, int y, default 2) { // Default parameter.
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1) == 3);
+ //]
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/add_default_seq.cpp b/src/boost/libs/local_function/test/add_default_seq.cpp
new file mode 100644
index 000000000..8130a90d5
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_default_seq.cpp
@@ -0,0 +1,19 @@
+
+// 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/detail/lightweight_test.hpp>
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION( (int x) (int y)(default 2) ) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1) == 3);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/add_default_seq_nova.cpp b/src/boost/libs/local_function/test/add_default_seq_nova.cpp
new file mode 100644
index 000000000..92e4ea776
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_default_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "add_default_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/add_except.cpp b/src/boost/libs/local_function/test/add_except.cpp
new file mode 100644
index 000000000..c3a148851
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_except.cpp
@@ -0,0 +1,34 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[add_except
+ double sum = 0.0;
+ int factor = 10;
+
+ void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum,
+ double num) throw() { // Throw nothing.
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(100);
+ //]
+
+ BOOST_TEST(sum == 1000);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/add_except_seq.cpp b/src/boost/libs/local_function/test/add_except_seq.cpp
new file mode 100644
index 000000000..be1d18605
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_except_seq.cpp
@@ -0,0 +1,25 @@
+
+// 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/detail/lightweight_test.hpp>
+
+int main(void) {
+ double sum = 0.0;
+ int factor = 10;
+
+ void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum)
+ (double num) ) throw() {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(100);
+
+ BOOST_TEST(sum == 1000);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/add_except_seq_nova.cpp b/src/boost/libs/local_function/test/add_except_seq_nova.cpp
new file mode 100644
index 000000000..44f53a29b
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_except_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "add_except_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/add_inline.cpp b/src/boost/libs/local_function/test/add_inline.cpp
new file mode 100644
index 000000000..4d3afe5c7
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_inline.cpp
@@ -0,0 +1,37 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+int main(void) {
+ //[add_inline
+ int sum = 0, factor = 10;
+
+ void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum, int num) {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(inline add) // Inlining.
+
+ std::vector<int> v(100);
+ std::fill(v.begin(), v.end(), 1);
+
+ for(size_t i = 0; i < v.size(); ++i) add(v[i]); // Cannot use for_each.
+ //]
+
+ BOOST_TEST(sum == 1000);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/add_inline_seq.cpp b/src/boost/libs/local_function/test/add_inline_seq.cpp
new file mode 100644
index 000000000..780262152
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_inline_seq.cpp
@@ -0,0 +1,28 @@
+
+// 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/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+int main(void) {
+ int sum = 0, factor = 10;
+
+ void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(inline add)
+
+ std::vector<int> v(100);
+ std::fill(v.begin(), v.end(), 1);
+
+ for(size_t i = 0; i < v.size(); ++i) add(v[i]);
+
+ BOOST_TEST(sum == 1000);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/add_inline_seq_nova.cpp b/src/boost/libs/local_function/test/add_inline_seq_nova.cpp
new file mode 100644
index 000000000..e040ad6d1
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_inline_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "add_inline_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/add_params_only.cpp b/src/boost/libs/local_function/test/add_params_only.cpp
new file mode 100644
index 000000000..3b9b93d99
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_params_only.cpp
@@ -0,0 +1,28 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[add_params_only
+ int BOOST_LOCAL_FUNCTION(int x, int y) { // Local function.
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1, 2) == 3); // Local function call.
+ //]
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/add_params_only_seq.cpp b/src/boost/libs/local_function/test/add_params_only_seq.cpp
new file mode 100644
index 000000000..565d5ff90
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_params_only_seq.cpp
@@ -0,0 +1,19 @@
+
+// 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/detail/lightweight_test.hpp>
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION( (int x) (int y) ) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1, 2) == 3);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/add_params_only_seq_nova.cpp b/src/boost/libs/local_function/test/add_params_only_seq_nova.cpp
new file mode 100644
index 000000000..7123aae8a
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_params_only_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "add_params_only_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/add_seq.cpp b/src/boost/libs/local_function/test/add_seq.cpp
new file mode 100644
index 000000000..d04819b2c
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_seq.cpp
@@ -0,0 +1,28 @@
+
+// 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/detail/lightweight_test.hpp>
+#include <algorithm>
+
+//[add_seq
+int main(void) {
+ int sum = 0, factor = 10;
+
+ void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(1);
+ int nums[] = {2, 3};
+ std::for_each(nums, nums + 2, add);
+
+ BOOST_TEST(sum == 60);
+ return boost::report_errors();
+}
+//]
+
diff --git a/src/boost/libs/local_function/test/add_seq_nova.cpp b/src/boost/libs/local_function/test/add_seq_nova.cpp
new file mode 100644
index 000000000..ce0c279f5
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "add_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/add_template.cpp b/src/boost/libs/local_function/test/add_template.cpp
new file mode 100644
index 000000000..aa382673b
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_template.cpp
@@ -0,0 +1,41 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+//[add_template
+template<typename T>
+T total(const T& x, const T& y, const T& z) {
+ T sum = T(), factor = 10;
+
+ // Must use the `..._TPL` macros within templates.
+ T BOOST_LOCAL_FUNCTION_TPL(const bind factor, bind& sum, T num) {
+ return sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(add)
+
+ add(x);
+ T nums[2]; nums[0] = y; nums[1] = z;
+ std::for_each(nums, nums + 2, add);
+
+ return sum;
+}
+//]
+
+int main(void) {
+ BOOST_TEST(total(1, 2, 3) == 60);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/add_template_seq.cpp b/src/boost/libs/local_function/test/add_template_seq.cpp
new file mode 100644
index 000000000..3c0ea7155
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_template_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/detail/lightweight_test.hpp>
+#include <algorithm>
+
+template<typename T>
+T total(const T& x, const T& y, const T& z) {
+ T sum = T(), factor = 10;
+
+ T BOOST_LOCAL_FUNCTION_TPL( (const bind factor) (bind& sum) (T num) ) {
+ return sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(add)
+
+ add(x);
+ T nums[2]; nums[0] = y; nums[1] = z;
+ std::for_each(nums, nums + 2, add);
+
+ return sum;
+}
+
+int main(void) {
+ BOOST_TEST(total(1, 2, 3) == 60);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/add_template_seq_nova.cpp b/src/boost/libs/local_function/test/add_template_seq_nova.cpp
new file mode 100644
index 000000000..9c02384b1
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_template_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "add_template_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/add_this.cpp b/src/boost/libs/local_function/test/add_this.cpp
new file mode 100644
index 000000000..f42404367
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_this.cpp
@@ -0,0 +1,51 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+struct adder;
+BOOST_TYPEOF_REGISTER_TYPE(adder) // Register before `bind this_` below.
+
+//[add_this
+struct adder {
+ adder() : sum_(0) {}
+
+ int sum(const std::vector<int>& nums, const int factor = 10) {
+
+ void BOOST_LOCAL_FUNCTION(const bind factor, bind this_, int num) {
+ this_->sum_ += factor * num; // Use `this_` instead of `this`.
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ std::for_each(nums.begin(), nums.end(), add);
+ return sum_;
+ }
+
+private:
+ int sum_;
+};
+//]
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 2; v[2] = 3;
+
+ BOOST_TEST(adder().sum(v) == 60);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/add_this_seq.cpp b/src/boost/libs/local_function/test/add_this_seq.cpp
new file mode 100644
index 000000000..9957122e7
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_this_seq.cpp
@@ -0,0 +1,43 @@
+
+// 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/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+struct adder;
+BOOST_TYPEOF_REGISTER_TYPE(adder) // Register before `bind this_` below.
+
+struct adder {
+ adder() : sum_(0) {}
+
+ int sum(const std::vector<int>& nums, const int factor = 10) {
+
+ void BOOST_LOCAL_FUNCTION( (const bind factor) (bind this_)
+ (int num) ) {
+ this_->sum_ += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ std::for_each(nums.begin(), nums.end(), add);
+ return sum_;
+ }
+
+private:
+ int sum_;
+};
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 2; v[2] = 3;
+
+ BOOST_TEST(adder().sum(v) == 60);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/add_this_seq_nova.cpp b/src/boost/libs/local_function/test/add_this_seq_nova.cpp
new file mode 100644
index 000000000..e01573908
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_this_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "add_this_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/add_typed.cpp b/src/boost/libs/local_function/test/add_typed.cpp
new file mode 100644
index 000000000..6912a334b
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_typed.cpp
@@ -0,0 +1,47 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+//[add_typed
+struct adder {
+ adder(void) : sum_(0) {}
+
+ int sum(const std::vector<int>& nums, const int& factor = 10) {
+ // Explicitly specify bound variable and return types (no type-of).
+ BOOST_LOCAL_FUNCTION(const bind(const int&) factor,
+ bind(adder*) this_, int num, return int) {
+ return this_->sum_ += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ std::for_each(nums.begin(), nums.end(), add);
+ return sum_;
+ }
+
+private:
+ int sum_;
+};
+//]
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 2; v[2] = 3;
+
+ BOOST_TEST(adder().sum(v) == 60);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/add_typed_seq.cpp b/src/boost/libs/local_function/test/add_typed_seq.cpp
new file mode 100644
index 000000000..e62ff505c
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_typed_seq.cpp
@@ -0,0 +1,37 @@
+
+// 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/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+struct adder {
+ adder(void) : sum_(0) {}
+
+ int sum(const std::vector<int>& nums, const int& factor = 10) {
+ BOOST_LOCAL_FUNCTION( (const bind(const int&) factor)
+ (bind(adder*) this_) (int num) (return int) ) {
+ return this_->sum_ += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ std::for_each(nums.begin(), nums.end(), add);
+ return sum_;
+ }
+
+private:
+ int sum_;
+};
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 2; v[2] = 3;
+
+ BOOST_TEST(adder().sum(v) == 60);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/add_typed_seq_nova.cpp b/src/boost/libs/local_function/test/add_typed_seq_nova.cpp
new file mode 100644
index 000000000..0cdb35615
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_typed_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "add_typed_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/add_with_default.cpp b/src/boost/libs/local_function/test/add_with_default.cpp
new file mode 100644
index 000000000..f31cb1c63
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_with_default.cpp
@@ -0,0 +1,32 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+//[add_with_default_macro
+#define WITH_DEFAULT , default
+//]
+
+int main(void) {
+ //[add_with_default
+ int BOOST_LOCAL_FUNCTION(int x, int y WITH_DEFAULT 2) { // Default.
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1) == 3);
+ //]
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/add_with_default_seq.cpp b/src/boost/libs/local_function/test/add_with_default_seq.cpp
new file mode 100644
index 000000000..1513af021
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_with_default_seq.cpp
@@ -0,0 +1,21 @@
+
+// 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/detail/lightweight_test.hpp>
+
+#define WITH_DEFAULT )(default
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION( (int x) (int y WITH_DEFAULT 2) ) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1) == 3);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/add_with_default_seq_nova.cpp b/src/boost/libs/local_function/test/add_with_default_seq_nova.cpp
new file mode 100644
index 000000000..d7149cc78
--- /dev/null
+++ b/src/boost/libs/local_function/test/add_with_default_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "add_with_default_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/addable.hpp b/src/boost/libs/local_function/test/addable.hpp
new file mode 100644
index 000000000..3b13ab288
--- /dev/null
+++ b/src/boost/libs/local_function/test/addable.hpp
@@ -0,0 +1,26 @@
+
+// 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
+
+#ifndef ADDABLE_HPP_
+#define ADDABLE_HPP_
+
+#include <boost/concept_check.hpp>
+
+template<typename T>
+struct Addable { // User-defined concept.
+ BOOST_CONCEPT_USAGE(Addable) {
+ return_type(x + y); // Check addition `T operator+(T x, T y)`.
+ }
+
+private:
+ void return_type(T) {} // Implementation (required for some linkers).
+ static T const& x;
+ static T const& y;
+};
+
+#endif // #include guard
+
diff --git a/src/boost/libs/local_function/test/all_decl.cpp b/src/boost/libs/local_function/test/all_decl.cpp
new file mode 100644
index 000000000..a9a63db1c
--- /dev/null
+++ b/src/boost/libs/local_function/test/all_decl.cpp
@@ -0,0 +1,177 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+struct s;
+BOOST_TYPEOF_REGISTER_TYPE(s) // Register before binding `this_` below.
+
+// Compile all local function declaration combinations.
+struct s {
+ void f(double p = 1.23, double q = -1.23) {
+ { // Only params.
+ void BOOST_LOCAL_FUNCTION(int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+ }
+ { // Only const binds.
+ int a, b;
+
+ const int& BOOST_LOCAL_FUNCTION(const bind a,
+ const bind& b, const bind& p, const bind q) {
+ return b;
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ const s& BOOST_LOCAL_FUNCTION(const bind this_) {
+ return *this_;
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t();
+
+ const int BOOST_LOCAL_FUNCTION(const bind a,
+ const bind& b, const bind& p, const bind q,
+ const bind this_) {
+ return a;
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt();
+ }
+ { // Only plain binds.
+ int c, d;
+
+ int& BOOST_LOCAL_FUNCTION(bind c, bind& d,
+ bind& p, bind& q) {
+ return d;
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ s& BOOST_LOCAL_FUNCTION(bind this_) {
+ return *this_;
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t();
+
+ int BOOST_LOCAL_FUNCTION(bind c, bind& d,
+ bind& p, bind& q, bind this_) {
+ return c;
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt();
+ }
+
+ { // Both params and const binds.
+ int a, b;
+
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
+ const bind& p, const bind q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION(const bind this_,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t(1);
+
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind this_,
+ const bind& b, const bind& p, const bind q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt(1);
+ }
+ { // Both params and plain binds.
+ int c, d;
+
+ void BOOST_LOCAL_FUNCTION(bind c, bind& d, bind& p, bind q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION(bind this_,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t(1);
+
+ void BOOST_LOCAL_FUNCTION(bind c, bind& d,
+ bind& p, bind this_, bind q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt(1);
+ }
+ { // Both const and plain binds.
+ int a, b, c, d;
+
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
+ const bind p, bind c, bind& d, bind q) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ void BOOST_LOCAL_FUNCTION(const bind this_,
+ bind c, bind& d, bind q) {
+ } BOOST_LOCAL_FUNCTION_NAME(ct)
+ ct();
+ void BOOST_LOCAL_FUNCTION(const bind this_,
+ const bind a, const bind& b, const bind p,
+ bind c, bind& d, bind q) {
+ } BOOST_LOCAL_FUNCTION_NAME(lct)
+ lct();
+
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
+ const bind p, bind this_) {
+ } BOOST_LOCAL_FUNCTION_NAME(pt)
+ pt();
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
+ const bind p, bind c, bind this_, bind& d, bind q) {
+ } BOOST_LOCAL_FUNCTION_NAME(lpt)
+ lpt();
+ }
+
+ { // All params, const binds, and plain binds.
+ int a, b, c, d;
+
+ void BOOST_LOCAL_FUNCTION(
+ const bind a, const bind& b, const bind& p,
+ bind c, bind& d, bind& q, int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION(const bind this_,
+ bind c, bind& d, bind& q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(ct)
+ ct(1);
+ void BOOST_LOCAL_FUNCTION(
+ const bind a, const bind& b, const bind& p,
+ bind this_, int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(pt)
+ pt(1);
+
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind this_,
+ const bind& b, const bind& p, bind c, bind& d,
+ bind& q, int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(lct)
+ lct(1);
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
+ const bind& p, bind c, bind& d, bind this_, bind& q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(lpt)
+ lpt(1);
+ }
+ }
+};
+
+int main(void) {
+ s().f();
+ return 0;
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/all_decl_seq.cpp b/src/boost/libs/local_function/test/all_decl_seq.cpp
new file mode 100644
index 000000000..95fb75ede
--- /dev/null
+++ b/src/boost/libs/local_function/test/all_decl_seq.cpp
@@ -0,0 +1,170 @@
+
+// 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/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+struct s;
+BOOST_TYPEOF_REGISTER_TYPE(s); // Register before bind `this_` below.
+
+// Compile all local function declaration combinations.
+struct s {
+ void f(double p = 1.23, double q = -1.23) {
+ { // Only params.
+ void BOOST_LOCAL_FUNCTION( (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+ }
+ { // Only const binds.
+ int a, b;
+
+ const int& BOOST_LOCAL_FUNCTION( (const bind a)
+ (const bind& b) (const bind& p) (const bind q) ) {
+ return b;
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ const s& BOOST_LOCAL_FUNCTION( (const bind this_) ) {
+ return *this_;
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t();
+
+ const int BOOST_LOCAL_FUNCTION( (const bind a)
+ (const bind& b) (const bind& p) (const bind q)
+ (const bind this_) ) {
+ return a;
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt();
+ }
+ { // Only plain binds.
+ int c, d;
+
+ int& BOOST_LOCAL_FUNCTION( (bind c) (bind& d)
+ (bind& p) (bind& q) ) {
+ return d;
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ s& BOOST_LOCAL_FUNCTION( (bind this_) ) {
+ return *this_;
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t();
+
+ int BOOST_LOCAL_FUNCTION( (bind c) (bind& d)
+ (bind& p) (bind& q) (bind this_) ) {
+ return c;
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt();
+ }
+
+ { // Both params and const binds.
+ int a, b;
+
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
+ (const bind& p) (const bind q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION( (const bind this_)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t(1);
+
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind this_)
+ (const bind& b) (const bind& p) (const bind q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt(1);
+ }
+ { // Both params and plain binds.
+ int c, d;
+
+ void BOOST_LOCAL_FUNCTION( (bind c) (bind& d) (bind& p) (bind q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION( (bind this_)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t(1);
+
+ void BOOST_LOCAL_FUNCTION( (bind c) (bind& d)
+ (bind& p) (bind this_) (bind q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt(1);
+ }
+ { // Both const and plain binds.
+ int a, b, c, d;
+
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
+ (const bind p) (bind c) (bind& d) (bind q) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ void BOOST_LOCAL_FUNCTION( (const bind this_)
+ (bind c) (bind& d) (bind q) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(ct)
+ ct();
+ void BOOST_LOCAL_FUNCTION( (const bind this_)
+ (const bind a) (const bind& b) (const bind p)
+ (bind c) (bind& d) (bind q) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lct)
+ lct();
+
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
+ (const bind p) (bind this_) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(pt)
+ pt();
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
+ (const bind p) (bind c) (bind this_) (bind& d) (bind q) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lpt)
+ lpt();
+ }
+
+ { // All params, const binds, and plain binds.
+ int a, b, c, d;
+
+ void BOOST_LOCAL_FUNCTION(
+ (const bind a) (const bind& b) (const bind& p)
+ (bind c) (bind& d) (bind& q) (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION( (const bind this_)
+ (bind c) (bind& d) (bind& q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(ct)
+ ct(1);
+ void BOOST_LOCAL_FUNCTION(
+ (const bind a) (const bind& b) (const bind& p)
+ (bind this_) (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(pt)
+ pt(1);
+
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind this_)
+ (const bind& b) (const bind& p) (bind c) (bind& d)
+ (bind& q) (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lct)
+ lct(1);
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
+ (const bind& p) (bind c) (bind& d) (bind this_) (bind& q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lpt)
+ lpt(1);
+ }
+ }
+};
+
+int main(void) {
+ s().f();
+ return 0;
+}
+
diff --git a/src/boost/libs/local_function/test/all_decl_seq_nova.cpp b/src/boost/libs/local_function/test/all_decl_seq_nova.cpp
new file mode 100644
index 000000000..8333b2857
--- /dev/null
+++ b/src/boost/libs/local_function/test/all_decl_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "all_decl_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/factorial.cpp b/src/boost/libs/local_function/test/factorial.cpp
new file mode 100644
index 000000000..7260de23a
--- /dev/null
+++ b/src/boost/libs/local_function/test/factorial.cpp
@@ -0,0 +1,57 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+#include <vector>
+
+struct calculator;
+BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before `bind this_` below.
+
+//[factorial
+struct calculator {
+ std::vector<int> results;
+
+ void factorials(const std::vector<int>& nums) {
+ int BOOST_LOCAL_FUNCTION(bind this_, int num,
+ bool recursion, default false) {
+ int result = 0;
+
+ if(num <= 0) result = 1;
+ else result = num * factorial(num - 1, true); // Recursive call.
+
+ if(!recursion) this_->results.push_back(result);
+ return result;
+ } BOOST_LOCAL_FUNCTION_NAME(recursive factorial) // Recursive.
+
+ std::for_each(nums.begin(), nums.end(), factorial);
+ }
+};
+//]
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 3; v[2] = 4;
+
+ calculator calc;
+ calc.factorials(v);
+ BOOST_TEST(calc.results[0] == 1);
+ BOOST_TEST(calc.results[1] == 6);
+ BOOST_TEST(calc.results[2] == 24);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/factorial_seq.cpp b/src/boost/libs/local_function/test/factorial_seq.cpp
new file mode 100644
index 000000000..e7c242c27
--- /dev/null
+++ b/src/boost/libs/local_function/test/factorial_seq.cpp
@@ -0,0 +1,48 @@
+
+// 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/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+#include <vector>
+
+struct calculator;
+BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before `bind this_` below.
+
+struct calculator {
+ std::vector<int> results;
+
+ void factorials(const std::vector<int>& nums) {
+ int BOOST_LOCAL_FUNCTION( (bind this_) (int num)
+ (bool recursion)(default false) ) {
+ int result = 0;
+
+ if(num <= 0) result = 1;
+ else result = num * factorial(num - 1, true);
+
+ if(!recursion) this_->results.push_back(result);
+ return result;
+ } BOOST_LOCAL_FUNCTION_NAME(recursive factorial)
+
+ std::for_each(nums.begin(), nums.end(), factorial);
+ }
+};
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 3; v[2] = 4;
+
+ calculator calc;
+ calc.factorials(v);
+ BOOST_TEST(calc.results[0] == 1);
+ BOOST_TEST(calc.results[1] == 6);
+ BOOST_TEST(calc.results[2] == 24);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/factorial_seq_nova.cpp b/src/boost/libs/local_function/test/factorial_seq_nova.cpp
new file mode 100644
index 000000000..b9376125a
--- /dev/null
+++ b/src/boost/libs/local_function/test/factorial_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "factorial_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/goto.cpp b/src/boost/libs/local_function/test/goto.cpp
new file mode 100644
index 000000000..a6dda7512
--- /dev/null
+++ b/src/boost/libs/local_function/test/goto.cpp
@@ -0,0 +1,34 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+
+//[goto
+int error(int x, int y) {
+ int BOOST_LOCAL_FUNCTION(int z) {
+ if(z > 0) goto success; // OK: Can jump within local function.
+ return -1;
+ success:
+ return 0;
+ } BOOST_LOCAL_FUNCTION_NAME(validate)
+
+ return validate(x + y);
+}
+//]
+
+int main(void) {
+ error(1, 2);
+ return 0;
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/goto_error.cpp b/src/boost/libs/local_function/test/goto_error.cpp
new file mode 100644
index 000000000..3ed397194
--- /dev/null
+++ b/src/boost/libs/local_function/test/goto_error.cpp
@@ -0,0 +1,36 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+
+//[goto_error
+int error(int x, int y) {
+ int BOOST_LOCAL_FUNCTION(int z) {
+ if(z <= 0) goto failure; // Error: Cannot jump to enclosing scope.
+ else goto success; // OK: Can jump within local function.
+ success:
+ return 0;
+ } BOOST_LOCAL_FUNCTION_NAME(validate)
+
+ return validate(x + y);
+failure:
+ return -1;
+}
+//]
+
+int main(void) {
+ error(1, 2);
+ return 0;
+}
+
+#endif
+
diff --git a/src/boost/libs/local_function/test/goto_error_seq.cpp b/src/boost/libs/local_function/test/goto_error_seq.cpp
new file mode 100644
index 000000000..178ac4372
--- /dev/null
+++ b/src/boost/libs/local_function/test/goto_error_seq.cpp
@@ -0,0 +1,27 @@
+
+// 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>
+
+int error(int x, int y) {
+ int BOOST_LOCAL_FUNCTION( (int z) ) {
+ if(z <= 0) goto failure;
+ else goto success;
+ success:
+ return 0;
+ } BOOST_LOCAL_FUNCTION_NAME(validate)
+
+ return validate(x + y);
+failure:
+ return -1;
+}
+
+int main(void) {
+ error(1, 2);
+ return 0;
+}
+
diff --git a/src/boost/libs/local_function/test/goto_error_seq_nova.cpp b/src/boost/libs/local_function/test/goto_error_seq_nova.cpp
new file mode 100644
index 000000000..6433add5c
--- /dev/null
+++ b/src/boost/libs/local_function/test/goto_error_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "goto_error_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/goto_seq.cpp b/src/boost/libs/local_function/test/goto_seq.cpp
new file mode 100644
index 000000000..5acb5b46d
--- /dev/null
+++ b/src/boost/libs/local_function/test/goto_seq.cpp
@@ -0,0 +1,25 @@
+
+// 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>
+
+int error(int x, int y) {
+ int BOOST_LOCAL_FUNCTION( (int z) ) {
+ if(z > 0) goto success;
+ return -1;
+ success:
+ return 0;
+ } BOOST_LOCAL_FUNCTION_NAME(validate)
+
+ return validate(x + y);
+}
+
+int main(void) {
+ error(1, 2);
+ return 0;
+}
+
diff --git a/src/boost/libs/local_function/test/goto_seq_nova.cpp b/src/boost/libs/local_function/test/goto_seq_nova.cpp
new file mode 100644
index 000000000..edec9f283
--- /dev/null
+++ b/src/boost/libs/local_function/test/goto_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "goto_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/macro_commas.cpp b/src/boost/libs/local_function/test/macro_commas.cpp
new file mode 100644
index 000000000..3905782f6
--- /dev/null
+++ b/src/boost/libs/local_function/test/macro_commas.cpp
@@ -0,0 +1,52 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/utility/identity_type.hpp>
+#include <boost/typeof/std/string.hpp> // Type-of registrations
+#include <boost/typeof/std/map.hpp> // needed for `NAME` macro.
+#include <map>
+#include <string>
+
+std::string cat(const std::string& x, const std::string& y) { return x + y; }
+
+template<typename V, typename K>
+struct key_sizeof {
+ static int const value;
+};
+
+template<typename V, typename K>
+int const key_sizeof<V, K>::value = sizeof(K);
+
+typedef int sign_t;
+
+int main(void) {
+ //[macro_commas
+ void BOOST_LOCAL_FUNCTION(
+ BOOST_IDENTITY_TYPE((const std::map<std::string, size_t>&)) m,
+ BOOST_IDENTITY_TYPE((::sign_t)) sign,
+ const size_t& factor,
+ default (key_sizeof<std::string, size_t>::value),
+ const std::string& separator, default cat(":", " ")
+ ) {
+ // Do something...
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+ //]
+
+ std::map<std::string, size_t> m;
+ ::sign_t sign = -1;
+ f(m, sign);
+ return 0;
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/macro_commas_seq.cpp b/src/boost/libs/local_function/test/macro_commas_seq.cpp
new file mode 100644
index 000000000..f2e0f49af
--- /dev/null
+++ b/src/boost/libs/local_function/test/macro_commas_seq.cpp
@@ -0,0 +1,44 @@
+
+// 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/utility/identity_type.hpp>
+#include <boost/typeof/std/string.hpp> // Type-of registrations
+#include <boost/typeof/std/map.hpp> // needed for `NAME` macro.
+#include <boost/config.hpp>
+#include <map>
+#include <string>
+
+std::string cat(const std::string& x, const std::string& y) { return x + y; }
+
+template<typename V, typename K>
+struct key_sizeof {
+ static int const value;
+};
+
+template<typename V, typename K>
+int const key_sizeof<V, K>::value = sizeof(K);
+
+typedef int sign_t;
+
+int main(void) {
+ void BOOST_LOCAL_FUNCTION(
+ (BOOST_IDENTITY_TYPE((const std::map<std::string, size_t>&)) m)
+ (BOOST_IDENTITY_TYPE((::sign_t)) sign)
+ (const size_t& factor)
+ (default (key_sizeof<std::string, size_t>::value))
+ (const std::string& separator)(default cat(":", " "))
+ ) {
+ // Do something...
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+ std::map<std::string, size_t> m;
+ ::sign_t sign = -1;
+ f(m, sign);
+ return 0;
+}
+
diff --git a/src/boost/libs/local_function/test/macro_commas_seq_nova.cpp b/src/boost/libs/local_function/test/macro_commas_seq_nova.cpp
new file mode 100644
index 000000000..4252379d6
--- /dev/null
+++ b/src/boost/libs/local_function/test/macro_commas_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "macro_commas_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/nesting.cpp b/src/boost/libs/local_function/test/nesting.cpp
new file mode 100644
index 000000000..e13ac2692
--- /dev/null
+++ b/src/boost/libs/local_function/test/nesting.cpp
@@ -0,0 +1,37 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[nesting
+ int x = 0;
+
+ void BOOST_LOCAL_FUNCTION(bind& x) {
+ void BOOST_LOCAL_FUNCTION(bind& x) { // Nested.
+ x++;
+ } BOOST_LOCAL_FUNCTION_NAME(g)
+
+ x--;
+ g(); // Nested local function call.
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+ f();
+ //]
+
+ BOOST_TEST(x == 0);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/nesting_seq.cpp b/src/boost/libs/local_function/test/nesting_seq.cpp
new file mode 100644
index 000000000..6e18558bf
--- /dev/null
+++ b/src/boost/libs/local_function/test/nesting_seq.cpp
@@ -0,0 +1,28 @@
+
+// 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/detail/lightweight_test.hpp>
+
+int main(void) {
+ int x = 0;
+
+ void BOOST_LOCAL_FUNCTION( (bind& x) ) {
+ void BOOST_LOCAL_FUNCTION( (bind& x) ) {
+ x++;
+ } BOOST_LOCAL_FUNCTION_NAME(g)
+
+ x--;
+ g();
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+ f();
+
+ BOOST_TEST(x == 0);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/nesting_seq_nova.cpp b/src/boost/libs/local_function/test/nesting_seq_nova.cpp
new file mode 100644
index 000000000..caeb0720c
--- /dev/null
+++ b/src/boost/libs/local_function/test/nesting_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "nesting_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/nova.hpp b/src/boost/libs/local_function/test/nova.hpp
new file mode 100644
index 000000000..ceef87eed
--- /dev/null
+++ b/src/boost/libs/local_function/test/nova.hpp
@@ -0,0 +1,21 @@
+
+// Copyright (C) 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/scope_exit
+
+#ifndef NOVA_HPP_
+#define NOVA_HPP_
+
+#include <boost/config.hpp>
+
+// WARNING: This file must be included first in each compilation unit.
+
+// Force no variadic macros but avoiding macro redefinition warning/error.
+#ifndef BOOST_NO_CXX11_VARIADIC_MACROS
+# define BOOST_NO_CXX11_VARIADIC_MACROS
+#endif
+
+#endif // #include guard
+
diff --git a/src/boost/libs/local_function/test/operator.cpp b/src/boost/libs/local_function/test/operator.cpp
new file mode 100644
index 000000000..c8911c3e4
--- /dev/null
+++ b/src/boost/libs/local_function/test/operator.cpp
@@ -0,0 +1,38 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+//[operator
+struct point {
+ int x;
+ int y;
+};
+BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below.
+
+int main(void) {
+ bool BOOST_LOCAL_FUNCTION(const point& p, const point& q) {
+ return p.x == q.x && p.y == q.y;
+ } BOOST_LOCAL_FUNCTION_NAME(equal) // OK: not using `operator==`.
+
+ point a; a.x = 1; a.y = 2;
+ point b = a;
+ BOOST_TEST(equal(a, b));
+ return boost::report_errors();
+}
+//]
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/operator_error.cpp b/src/boost/libs/local_function/test/operator_error.cpp
new file mode 100644
index 000000000..9fd81f622
--- /dev/null
+++ b/src/boost/libs/local_function/test/operator_error.cpp
@@ -0,0 +1,38 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+struct point {
+ int x;
+ int y;
+};
+BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below.
+
+int main(void) {
+ //[operator_error
+ bool BOOST_LOCAL_FUNCTION(const point& p, const point& q) {
+ return p.x == q.x && p.y == q.y;
+ } BOOST_LOCAL_FUNCTION_NAME(operator==) // Error: Cannot use `operator...`.
+ //]
+
+ point a; a.x = 1; a.y = 2;
+ point b = a;
+ BOOST_TEST(a == b);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/operator_error_seq.cpp b/src/boost/libs/local_function/test/operator_error_seq.cpp
new file mode 100644
index 000000000..08c21f2a1
--- /dev/null
+++ b/src/boost/libs/local_function/test/operator_error_seq.cpp
@@ -0,0 +1,29 @@
+
+// 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/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+struct point {
+ int x;
+ int y;
+};
+BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below.
+
+int main(void) {
+ bool BOOST_LOCAL_FUNCTION( (const point& p) (const point& q) ) {
+ return p.x == q.x && p.y == q.y;
+ } BOOST_LOCAL_FUNCTION_NAME(operator==)
+
+ point a; a.x = 1; a.y = 2;
+ point b = a;
+ BOOST_TEST(a == b);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/operator_error_seq_nova.cpp b/src/boost/libs/local_function/test/operator_error_seq_nova.cpp
new file mode 100644
index 000000000..6df7178ab
--- /dev/null
+++ b/src/boost/libs/local_function/test/operator_error_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "operator_error_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/operator_seq.cpp b/src/boost/libs/local_function/test/operator_seq.cpp
new file mode 100644
index 000000000..d4f70f450
--- /dev/null
+++ b/src/boost/libs/local_function/test/operator_seq.cpp
@@ -0,0 +1,29 @@
+
+// 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/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+struct point {
+ int x;
+ int y;
+};
+BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below.
+
+int main(void) {
+ bool BOOST_LOCAL_FUNCTION( (const point& p) (const point& q) ) {
+ return p.x == q.x && p.y == q.y;
+ } BOOST_LOCAL_FUNCTION_NAME(equal)
+
+ point a; a.x = 1; a.y = 2;
+ point b = a;
+ BOOST_TEST(equal(a, b));
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/operator_seq_nova.cpp b/src/boost/libs/local_function/test/operator_seq_nova.cpp
new file mode 100644
index 000000000..e6f624682
--- /dev/null
+++ b/src/boost/libs/local_function/test/operator_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "operator_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/overload.cpp b/src/boost/libs/local_function/test/overload.cpp
new file mode 100644
index 000000000..6a2c1eede
--- /dev/null
+++ b/src/boost/libs/local_function/test/overload.cpp
@@ -0,0 +1,52 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/functional/overloaded_function.hpp> // For overloading.
+#include <boost/typeof/std/string.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <string>
+
+//[overload_decl
+int add_i(int x, int y) { return x + y; }
+//]
+
+int main(void) {
+ //[overload
+ std::string s = "abc";
+ std::string BOOST_LOCAL_FUNCTION(
+ const bind& s, const std::string& x) {
+ return s + x;
+ } BOOST_LOCAL_FUNCTION_NAME(add_s)
+
+ double d = 1.23;
+ double BOOST_LOCAL_FUNCTION(const bind d, double x, double y, default 0) {
+ return d + x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add_d)
+
+ boost::overloaded_function<
+ std::string (const std::string&)
+ , double (double)
+ , double (double, double) // Overload giving default param.
+ , int (int, int)
+ > add(add_s, add_d, add_d, add_i); // Overloaded function object.
+
+ BOOST_TEST(add("xyz") == "abcxyz"); // Call `add_s`.
+ BOOST_TEST((4.44 - add(3.21)) <= 0.001); // Call `add_d` (no default).
+ BOOST_TEST((44.44 - add(3.21, 40.0)) <= 0.001); // Call `add_d`.
+ BOOST_TEST(add(1, 2) == 3); // Call `add_i`.
+ //]
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/overload_seq.cpp b/src/boost/libs/local_function/test/overload_seq.cpp
new file mode 100644
index 000000000..5bb0dab7d
--- /dev/null
+++ b/src/boost/libs/local_function/test/overload_seq.cpp
@@ -0,0 +1,42 @@
+
+// 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/functional/overloaded_function.hpp>
+#include <boost/typeof/std/string.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <string>
+
+int add_i(int x, int y) { return x + y; }
+
+int main(void) {
+ std::string s = "abc";
+ std::string BOOST_LOCAL_FUNCTION(
+ (const bind& s) (const std::string& x) ) {
+ return s + x;
+ } BOOST_LOCAL_FUNCTION_NAME(add_s)
+
+ double d = 1.23;
+ double BOOST_LOCAL_FUNCTION( (const bind d) (double x)
+ (double y)(default 0) ) {
+ return d + x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add_d)
+
+ boost::overloaded_function<
+ std::string (const std::string&)
+ , double (double)
+ , double (double, double)
+ , int (int, int)
+ > add(add_s, add_d, add_d, add_i);
+
+ BOOST_TEST(add("xyz") == "abcxyz");
+ BOOST_TEST((4.44 - add(3.21)) <= 0.001); // Equal within precision.
+ BOOST_TEST((44.44 - add(3.21, 40.0)) <= 0.001); // Equal within precision.
+ BOOST_TEST(add(1, 2) == 3);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/overload_seq_nova.cpp b/src/boost/libs/local_function/test/overload_seq_nova.cpp
new file mode 100644
index 000000000..e72b63bde
--- /dev/null
+++ b/src/boost/libs/local_function/test/overload_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "overload_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/return_assign.cpp b/src/boost/libs/local_function/test/return_assign.cpp
new file mode 100644
index 000000000..6637ffa92
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_assign.cpp
@@ -0,0 +1,49 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+//[return_assign
+void call1(boost::function<int (int) > f) { BOOST_TEST(f(1) == 5); }
+void call0(boost::function<int (void)> f) { BOOST_TEST(f() == 5); }
+
+boost::function<int (int, int)> linear(const int& slope) {
+ int BOOST_LOCAL_FUNCTION(const bind& slope,
+ int x, default 1, int y, default 2) {
+ return x + slope * y;
+ } BOOST_LOCAL_FUNCTION_NAME(lin)
+
+ boost::function<int (int, int)> f = lin; // Assign to local variable.
+ BOOST_TEST(f(1, 2) == 5);
+
+ call1(lin); // Pass to other functions.
+ call0(lin);
+
+ return lin; // Return.
+}
+
+void call(void) {
+ boost::function<int (int, int)> f = linear(2);
+ BOOST_TEST(f(1, 2) == 5);
+}
+//]
+
+int main(void) {
+ call();
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/return_assign_seq.cpp b/src/boost/libs/local_function/test/return_assign_seq.cpp
new file mode 100644
index 000000000..95c6bf15e
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_assign_seq.cpp
@@ -0,0 +1,40 @@
+
+// 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>
+#include <iostream>
+
+void call1(boost::function<int (int) > f) { BOOST_TEST(f(1) == 5); }
+void call0(boost::function<int (void)> f) { BOOST_TEST(f() == 5); }
+
+boost::function<int (int, int)> linear(const int& slope) {
+ int BOOST_LOCAL_FUNCTION( (const bind& slope)
+ (int x)(default 1) (int y)(default 2) ) {
+ return x + slope * y;
+ } BOOST_LOCAL_FUNCTION_NAME(lin)
+
+ boost::function<int (int, int)> f = lin;
+ BOOST_TEST(f(1, 2) == 5);
+
+ call1(lin);
+ call0(lin);
+
+ return lin;
+}
+
+void call(void) {
+ boost::function<int (int, int)> f = linear(2);
+ BOOST_TEST(f(1, 2) == 5);
+}
+
+int main(void) {
+ call();
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/return_assign_seq_nova.cpp b/src/boost/libs/local_function/test/return_assign_seq_nova.cpp
new file mode 100644
index 000000000..12de8da2d
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_assign_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "return_assign_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/return_derivative.cpp b/src/boost/libs/local_function/test/return_derivative.cpp
new file mode 100644
index 000000000..746199132
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_derivative.cpp
@@ -0,0 +1,41 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function, 1)
+
+boost::function<int (int)> derivative(boost::function<int (int)>& f, int dx) {
+ int BOOST_LOCAL_FUNCTION(bind& f, const bind dx, int x) {
+ return (f(x + dx) - f(x)) / dx;
+ } BOOST_LOCAL_FUNCTION_NAME(deriv)
+
+ return deriv;
+}
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION(int x) {
+ return x + 4;
+ } BOOST_LOCAL_FUNCTION_NAME(add2)
+
+ boost::function<int (int)> a2 = add2; // Reference valid where closure used.
+ boost::function<int (int)> d2 = derivative(a2, 2);
+ BOOST_TEST(d2(6) == 1);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/return_derivative_seq.cpp b/src/boost/libs/local_function/test/return_derivative_seq.cpp
new file mode 100644
index 000000000..72c207425
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_derivative_seq.cpp
@@ -0,0 +1,34 @@
+
+// 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/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function, 1)
+
+boost::function<int (int)> derivative(boost::function<int (int)>& f, int dx) {
+ int BOOST_LOCAL_FUNCTION( (bind& f) (const bind dx) (int x) ) {
+ return (f(x + dx) - f(x)) / dx;
+ } BOOST_LOCAL_FUNCTION_NAME(deriv)
+
+ return deriv;
+}
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION( (int x) ) {
+ return x + 4;
+ } BOOST_LOCAL_FUNCTION_NAME(add2)
+
+ boost::function<int (int)> a2 = add2;
+ boost::function<int (int)> d2 = derivative(a2, 2);
+ BOOST_TEST(d2(6) == 1);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/return_derivative_seq_nova.cpp b/src/boost/libs/local_function/test/return_derivative_seq_nova.cpp
new file mode 100644
index 000000000..49bccdda3
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_derivative_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "return_derivative_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/return_inc.cpp b/src/boost/libs/local_function/test/return_inc.cpp
new file mode 100644
index 000000000..7d3e4248c
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_inc.cpp
@@ -0,0 +1,38 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#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; // Reference valid in scope where closure is used.
+ 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();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/return_inc_seq.cpp b/src/boost/libs/local_function/test/return_inc_seq.cpp
new file mode 100644
index 000000000..6116ea990
--- /dev/null
+++ b/src/boost/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();
+}
+
diff --git a/src/boost/libs/local_function/test/return_inc_seq_nova.cpp b/src/boost/libs/local_function/test/return_inc_seq_nova.cpp
new file mode 100644
index 000000000..c55ade6df
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_inc_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "return_inc_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/return_setget.cpp b/src/boost/libs/local_function/test/return_setget.cpp
new file mode 100644
index 000000000..1eb904c54
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_setget.cpp
@@ -0,0 +1,47 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/typeof/std/string.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <string>
+
+boost::function<void (const std::string&)> set;
+boost::function<const std::string& (void)> get;
+
+void action(void) {
+ // State `message` hidden behind access functions from here.
+ BOOST_TEST(get() == "abc");
+ set("xyz");
+ BOOST_TEST(get() == "xyz");
+}
+
+int main(void) {
+ std::string message = "abc"; // Reference valid where closure used.
+
+ void BOOST_LOCAL_FUNCTION(bind& message, const std::string& text) {
+ message = text;
+ } BOOST_LOCAL_FUNCTION_NAME(s)
+ set = s;
+
+ const std::string& BOOST_LOCAL_FUNCTION(const bind& message) {
+ return message;
+ } BOOST_LOCAL_FUNCTION_NAME(g)
+ get = g;
+
+ action();
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/return_setget_seq.cpp b/src/boost/libs/local_function/test/return_setget_seq.cpp
new file mode 100644
index 000000000..33b1c35dd
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_setget_seq.cpp
@@ -0,0 +1,39 @@
+
+// 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/typeof/std/string.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <string>
+
+boost::function<void (const std::string&)> set;
+boost::function<const std::string& (void)> get;
+
+void action(void) {
+ BOOST_TEST(get() == "abc");
+ set("xyz");
+ BOOST_TEST(get() == "xyz");
+}
+
+int main(void) {
+ std::string message = "abc";
+
+ void BOOST_LOCAL_FUNCTION( (bind& message) (const std::string& text) ) {
+ message = text;
+ } BOOST_LOCAL_FUNCTION_NAME(s)
+ set = s;
+
+ const std::string& BOOST_LOCAL_FUNCTION( (const bind& message) ) {
+ return message;
+ } BOOST_LOCAL_FUNCTION_NAME(g)
+ get = g;
+
+ action();
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/return_setget_seq_nova.cpp b/src/boost/libs/local_function/test/return_setget_seq_nova.cpp
new file mode 100644
index 000000000..87e2bde4c
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_setget_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "return_setget_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/return_this.cpp b/src/boost/libs/local_function/test/return_this.cpp
new file mode 100644
index 000000000..ea3debc86
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_this.cpp
@@ -0,0 +1,50 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+struct number;
+BOOST_TYPEOF_REGISTER_TYPE(number) // Register before `bind this_` below.
+
+struct number {
+ number(int value) : value_(value) {}
+
+ boost::function<int (void)> inc(void) {
+ int BOOST_LOCAL_FUNCTION(bind this_) {
+ return ++this_->value_;
+ } BOOST_LOCAL_FUNCTION_NAME(i)
+ return i;
+ }
+
+private:
+ int value_;
+};
+
+int main(void) {
+ number n1 = 0; // Object valid in scope where closure is used.
+ boost::function<int (void)> inc1 = n1.inc();
+ number n2 = 0;
+ boost::function<int (void)> inc2 = n2.inc();
+
+ BOOST_TEST(inc1() == 1);
+ BOOST_TEST(inc1() == 2);
+ BOOST_TEST(inc2() == 1);
+ BOOST_TEST(inc1() == 3);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/return_this_seq.cpp b/src/boost/libs/local_function/test/return_this_seq.cpp
new file mode 100644
index 000000000..551d3e1b1
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_this_seq.cpp
@@ -0,0 +1,43 @@
+
+// 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/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+struct number;
+BOOST_TYPEOF_REGISTER_TYPE(number) // Register before `bind this_` below.
+
+struct number {
+ number(int value) : value_(value) {}
+
+ boost::function<int (void)> inc(void) {
+ int BOOST_LOCAL_FUNCTION( (bind this_) ) {
+ return ++this_->value_;
+ } BOOST_LOCAL_FUNCTION_NAME(i)
+ return i;
+ }
+
+private:
+ int value_;
+};
+
+int main(void) {
+ number n1 = 0; // Object valid in scope where closure is used.
+ boost::function<int (void)> inc1 = n1.inc();
+ number n2 = 0;
+ boost::function<int (void)> inc2 = n2.inc();
+
+ BOOST_TEST(inc1() == 1);
+ BOOST_TEST(inc1() == 2);
+ BOOST_TEST(inc2() == 1);
+ BOOST_TEST(inc1() == 3);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/return_this_seq_nova.cpp b/src/boost/libs/local_function/test/return_this_seq_nova.cpp
new file mode 100644
index 000000000..1f0cfc258
--- /dev/null
+++ b/src/boost/libs/local_function/test/return_this_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "return_this_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/same_line.cpp b/src/boost/libs/local_function/test/same_line.cpp
new file mode 100644
index 000000000..0809e024f
--- /dev/null
+++ b/src/boost/libs/local_function/test/same_line.cpp
@@ -0,0 +1,57 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+//[same_line
+#define LOCAL_INC_DEC(offset) \
+ int BOOST_LOCAL_FUNCTION_ID(BOOST_PP_CAT(inc, __LINE__), /* unique ID */ \
+ const bind offset, const int x) { \
+ return x + offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(inc) \
+ \
+ int BOOST_LOCAL_FUNCTION_ID(BOOST_PP_CAT(dec, __LINE__), \
+ const bind offset, const int x) { \
+ return x - offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(dec)
+
+#define LOCAL_INC_DEC_TPL(offset) \
+ T BOOST_LOCAL_FUNCTION_ID_TPL(BOOST_PP_CAT(inc, __LINE__), \
+ const bind offset, const T x) { \
+ return x + offset; \
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(inc) \
+ \
+ T BOOST_LOCAL_FUNCTION_ID_TPL(BOOST_PP_CAT(dec, __LINE__), \
+ const bind offset, const T x) { \
+ return x - offset; \
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(dec)
+
+template<typename T>
+void f(T& delta) {
+ LOCAL_INC_DEC_TPL(delta) // Multiple local functions on same line.
+ BOOST_TEST(dec(inc(123)) == 123);
+}
+
+int main(void) {
+ int delta = 10;
+ LOCAL_INC_DEC(delta) // Multiple local functions on same line.
+ BOOST_TEST(dec(inc(123)) == 123);
+ f(delta);
+ return boost::report_errors();
+}
+//]
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/same_line_seq.cpp b/src/boost/libs/local_function/test/same_line_seq.cpp
new file mode 100644
index 000000000..2113f4752
--- /dev/null
+++ b/src/boost/libs/local_function/test/same_line_seq.cpp
@@ -0,0 +1,48 @@
+
+// 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/preprocessor/cat.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+#define LOCAL_INC_DEC(offset) \
+ int BOOST_LOCAL_FUNCTION_ID(BOOST_PP_CAT(inc, __LINE__), /* unique ID */ \
+ (const bind offset) (const int x) ) { \
+ return x + offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(inc) \
+ \
+ int BOOST_LOCAL_FUNCTION_ID(BOOST_PP_CAT(dec, __LINE__), \
+ (const bind offset) (const int x) ) { \
+ return x - offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(dec)
+
+#define LOCAL_INC_DEC_TPL(offset) \
+ T BOOST_LOCAL_FUNCTION_ID_TPL(BOOST_PP_CAT(inc, __LINE__), \
+ (const bind offset) (const T x) ) { \
+ return x + offset; \
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(inc) \
+ \
+ T BOOST_LOCAL_FUNCTION_ID_TPL(BOOST_PP_CAT(dec, __LINE__), \
+ (const bind offset) (const T x) ) { \
+ return x - offset; \
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(dec)
+
+template<typename T>
+void f(T& delta) {
+ LOCAL_INC_DEC_TPL(delta) // Multiple local functions on same line.
+ BOOST_TEST(dec(inc(123)) == 123);
+}
+
+int main(void) {
+ int delta = 10;
+ LOCAL_INC_DEC(delta) // Declare local functions on same line using `_ID`.
+ BOOST_TEST(dec(inc(123)) == 123);
+ f(delta);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/same_line_seq_nova.cpp b/src/boost/libs/local_function/test/same_line_seq_nova.cpp
new file mode 100644
index 000000000..fb5cc174f
--- /dev/null
+++ b/src/boost/libs/local_function/test/same_line_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "same_line_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/ten_void.cpp b/src/boost/libs/local_function/test/ten_void.cpp
new file mode 100644
index 000000000..99bf1bfdb
--- /dev/null
+++ b/src/boost/libs/local_function/test/ten_void.cpp
@@ -0,0 +1,21 @@
+
+// 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/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[ten_void
+ int BOOST_LOCAL_FUNCTION(void) { // No parameter.
+ return 10;
+ } BOOST_LOCAL_FUNCTION_NAME(ten)
+
+ BOOST_TEST(ten() == 10);
+ //]
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/ten_void_nova.cpp b/src/boost/libs/local_function/test/ten_void_nova.cpp
new file mode 100644
index 000000000..64b01c56d
--- /dev/null
+++ b/src/boost/libs/local_function/test/ten_void_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "ten_void.cpp"
+
diff --git a/src/boost/libs/local_function/test/transform.cpp b/src/boost/libs/local_function/test/transform.cpp
new file mode 100644
index 000000000..0cdbe76bc
--- /dev/null
+++ b/src/boost/libs/local_function/test/transform.cpp
@@ -0,0 +1,47 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+#include <vector>
+
+int main(void) {
+ //[transform
+ int offset = 5;
+ std::vector<int> v;
+ std::vector<int> w;
+
+ for(int i = 1; i <= 2; ++i) v.push_back(i * 10);
+ BOOST_TEST(v[0] == 10); BOOST_TEST(v[1] == 20);
+ w.resize(v.size());
+
+ int BOOST_LOCAL_FUNCTION(const bind& offset, int i) {
+ return ++i + offset;
+ } BOOST_LOCAL_FUNCTION_NAME(inc)
+
+ std::transform(v.begin(), v.end(), w.begin(), inc);
+ BOOST_TEST(w[0] == 16); BOOST_TEST(w[1] == 26);
+
+ int BOOST_LOCAL_FUNCTION(bind& inc, int i, int j) {
+ return inc(i + j); // Call the other bound local function.
+ } BOOST_LOCAL_FUNCTION_NAME(inc_sum)
+
+ offset = 0;
+ std::transform(v.begin(), v.end(), w.begin(), v.begin(), inc_sum);
+ BOOST_TEST(v[0] == 27); BOOST_TEST(v[1] == 47);
+ //]
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/transform_seq.cpp b/src/boost/libs/local_function/test/transform_seq.cpp
new file mode 100644
index 000000000..b29514c45
--- /dev/null
+++ b/src/boost/libs/local_function/test/transform_seq.cpp
@@ -0,0 +1,39 @@
+
+// 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/detail/lightweight_test.hpp>
+#include <algorithm>
+#include <vector>
+
+int main(void) {
+ int offset = 5;
+ std::vector<int> v;
+ std::vector<int> w;
+
+ for(int i = 1; i <= 2; ++i) v.push_back(i * 10);
+ BOOST_TEST(v[0] == 10); BOOST_TEST(v[1] == 20);
+ w.resize(v.size());
+
+ int BOOST_LOCAL_FUNCTION( (const bind& offset) (int i) ) {
+ return ++i + offset;
+ } BOOST_LOCAL_FUNCTION_NAME(inc)
+
+ std::transform(v.begin(), v.end(), w.begin(), inc);
+ BOOST_TEST(w[0] == 16); BOOST_TEST(w[1] == 26);
+
+ int BOOST_LOCAL_FUNCTION( (bind& inc) (int i) (int j) ) {
+ return inc(i + j);
+ } BOOST_LOCAL_FUNCTION_NAME(inc_sum)
+
+ offset = 0;
+ std::transform(v.begin(), v.end(), w.begin(), v.begin(), inc_sum);
+ BOOST_TEST(v[0] == 27); BOOST_TEST(v[1] == 47);
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/transform_seq_nova.cpp b/src/boost/libs/local_function/test/transform_seq_nova.cpp
new file mode 100644
index 000000000..9f06e4fb1
--- /dev/null
+++ b/src/boost/libs/local_function/test/transform_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "transform_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/typeof.cpp b/src/boost/libs/local_function/test/typeof.cpp
new file mode 100644
index 000000000..aa347354a
--- /dev/null
+++ b/src/boost/libs/local_function/test/typeof.cpp
@@ -0,0 +1,41 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include "addable.hpp"
+#include <boost/local_function.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+int main(void) {
+ //[typeof
+ int sum = 0, factor = 10;
+
+ void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum, int num) {
+ // Type-of for concept checking.
+ BOOST_CONCEPT_ASSERT((Addable<boost::remove_reference<
+ BOOST_LOCAL_FUNCTION_TYPEOF(sum)>::type>));
+ // Type-of for declarations.
+ boost::remove_reference<BOOST_LOCAL_FUNCTION_TYPEOF(
+ factor)>::type mult = factor * num;
+ sum += mult;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(6);
+ //]
+ BOOST_TEST(sum == 60);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/typeof_seq.cpp b/src/boost/libs/local_function/test/typeof_seq.cpp
new file mode 100644
index 000000000..01dd4633e
--- /dev/null
+++ b/src/boost/libs/local_function/test/typeof_seq.cpp
@@ -0,0 +1,30 @@
+
+// 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 "addable.hpp"
+#include <boost/local_function.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+int main(void) {
+ int sum = 0, factor = 10;
+
+ void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) {
+ BOOST_CONCEPT_ASSERT((Addable<boost::remove_reference<
+ BOOST_LOCAL_FUNCTION_TYPEOF(sum)>::type>));
+ boost::remove_reference<BOOST_LOCAL_FUNCTION_TYPEOF(
+ factor)>::type mult = factor * num;
+ sum += mult;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(6);
+ BOOST_TEST(sum == 60);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/typeof_seq_nova.cpp b/src/boost/libs/local_function/test/typeof_seq_nova.cpp
new file mode 100644
index 000000000..bf8b982be
--- /dev/null
+++ b/src/boost/libs/local_function/test/typeof_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "typeof_seq.cpp"
+
diff --git a/src/boost/libs/local_function/test/typeof_template.cpp b/src/boost/libs/local_function/test/typeof_template.cpp
new file mode 100644
index 000000000..f74e49fcd
--- /dev/null
+++ b/src/boost/libs/local_function/test/typeof_template.cpp
@@ -0,0 +1,43 @@
+
+// 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/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include "addable.hpp"
+#include <boost/local_function.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+//[typeof_template
+template<typename T>
+T calculate(const T& factor) {
+ T sum = 0;
+
+ void BOOST_LOCAL_FUNCTION_TPL(const bind factor, bind& sum, T num) {
+ // Local function `TYPEOF` does not need `typename`.
+ BOOST_CONCEPT_ASSERT((Addable<typename boost::remove_reference<
+ BOOST_LOCAL_FUNCTION_TYPEOF(sum)>::type>));
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(add)
+
+ add(6);
+ return sum;
+}
+//]
+
+int main(void) {
+ BOOST_TEST(calculate(10) == 60);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/src/boost/libs/local_function/test/typeof_template_seq.cpp b/src/boost/libs/local_function/test/typeof_template_seq.cpp
new file mode 100644
index 000000000..60028e958
--- /dev/null
+++ b/src/boost/libs/local_function/test/typeof_template_seq.cpp
@@ -0,0 +1,33 @@
+
+// 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 "addable.hpp"
+#include <boost/local_function.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+template<typename T>
+T calculate(const T& factor) {
+ T sum = 0;
+
+ void BOOST_LOCAL_FUNCTION_TPL( (const bind factor) (bind& sum) (T num) ) {
+ BOOST_CONCEPT_ASSERT((Addable<typename boost::remove_reference<
+ BOOST_LOCAL_FUNCTION_TYPEOF(sum)>::type>));
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(add)
+
+ add(6);
+ return sum;
+}
+
+int main(void) {
+ BOOST_TEST(calculate(10) == 60);
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/local_function/test/typeof_template_seq_nova.cpp b/src/boost/libs/local_function/test/typeof_template_seq_nova.cpp
new file mode 100644
index 000000000..48df4d431
--- /dev/null
+++ b/src/boost/libs/local_function/test/typeof_template_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// 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 "nova.hpp"
+#include "typeof_template_seq.cpp"
+