summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/fusion/test/algorithm
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/fusion/test/algorithm')
-rw-r--r--src/boost/libs/fusion/test/algorithm/all.cpp70
-rw-r--r--src/boost/libs/fusion/test/algorithm/any.cpp57
-rw-r--r--src/boost/libs/fusion/test/algorithm/clear.cpp45
-rw-r--r--src/boost/libs/fusion/test/algorithm/copy.cpp26
-rw-r--r--src/boost/libs/fusion/test/algorithm/count.cpp41
-rw-r--r--src/boost/libs/fusion/test/algorithm/count_if.cpp46
-rw-r--r--src/boost/libs/fusion/test/algorithm/erase.cpp63
-rw-r--r--src/boost/libs/fusion/test/algorithm/erase_key.cpp74
-rw-r--r--src/boost/libs/fusion/test/algorithm/filter.cpp43
-rw-r--r--src/boost/libs/fusion/test/algorithm/filter_if.cpp77
-rw-r--r--src/boost/libs/fusion/test/algorithm/find.cpp79
-rw-r--r--src/boost/libs/fusion/test/algorithm/find_if.cpp69
-rw-r--r--src/boost/libs/fusion/test/algorithm/flatten.cpp57
-rw-r--r--src/boost/libs/fusion/test/algorithm/fold.cpp257
-rw-r--r--src/boost/libs/fusion/test/algorithm/fold.hpp212
-rw-r--r--src/boost/libs/fusion/test/algorithm/for_each.cpp83
-rw-r--r--src/boost/libs/fusion/test/algorithm/insert.cpp67
-rw-r--r--src/boost/libs/fusion/test/algorithm/insert_range.cpp71
-rw-r--r--src/boost/libs/fusion/test/algorithm/iter_fold.cpp10
-rw-r--r--src/boost/libs/fusion/test/algorithm/join.cpp28
-rw-r--r--src/boost/libs/fusion/test/algorithm/move.cpp27
-rw-r--r--src/boost/libs/fusion/test/algorithm/none.cpp58
-rw-r--r--src/boost/libs/fusion/test/algorithm/pop_back.cpp105
-rw-r--r--src/boost/libs/fusion/test/algorithm/pop_front.cpp46
-rw-r--r--src/boost/libs/fusion/test/algorithm/push_back.cpp72
-rw-r--r--src/boost/libs/fusion/test/algorithm/push_front.cpp55
-rw-r--r--src/boost/libs/fusion/test/algorithm/remove.cpp80
-rw-r--r--src/boost/libs/fusion/test/algorithm/remove_if.cpp78
-rw-r--r--src/boost/libs/fusion/test/algorithm/replace.cpp49
-rw-r--r--src/boost/libs/fusion/test/algorithm/replace_if.cpp52
-rw-r--r--src/boost/libs/fusion/test/algorithm/reverse.cpp49
-rw-r--r--src/boost/libs/fusion/test/algorithm/reverse_fold.cpp10
-rw-r--r--src/boost/libs/fusion/test/algorithm/reverse_iter_fold.cpp12
-rw-r--r--src/boost/libs/fusion/test/algorithm/segmented_find.cpp62
-rw-r--r--src/boost/libs/fusion/test/algorithm/segmented_find_if.cpp65
-rw-r--r--src/boost/libs/fusion/test/algorithm/segmented_fold.cpp63
-rw-r--r--src/boost/libs/fusion/test/algorithm/segmented_for_each.cpp140
-rw-r--r--src/boost/libs/fusion/test/algorithm/ticket-5490.cpp41
-rw-r--r--src/boost/libs/fusion/test/algorithm/transform.cpp157
-rw-r--r--src/boost/libs/fusion/test/algorithm/zip.cpp30
-rw-r--r--src/boost/libs/fusion/test/algorithm/zip2.cpp30
-rw-r--r--src/boost/libs/fusion/test/algorithm/zip_ignore.cpp28
42 files changed, 2784 insertions, 0 deletions
diff --git a/src/boost/libs/fusion/test/algorithm/all.cpp b/src/boost/libs/fusion/test/algorithm/all.cpp
new file mode 100644
index 000000000..7b5550732
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/all.cpp
@@ -0,0 +1,70 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2007 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/algorithm/query/all.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/mpl/vector_c.hpp>
+
+namespace
+{
+ struct search_for
+ {
+ explicit search_for(int in_search)
+ : search(in_search)
+ {}
+
+ template<typename T>
+ bool operator()(T const& v) const
+ {
+ return v == search;
+ }
+
+ int search;
+ };
+}
+
+int
+main()
+{
+ {
+ boost::fusion::vector<> t;
+ BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 < 4)));
+ BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 > 0)));
+ }
+
+ {
+ boost::fusion::vector<int, short, double> t(1, 2, 3.3);
+ BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 < 4)));
+ BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 > 0)));
+ }
+
+ {
+ boost::fusion::vector<int, short, double, long> t(1, 2, 3.3, 2);
+ BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 < 4)));
+ BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 > 0)));
+ }
+
+ {
+ boost::fusion::vector<int, short, double> t(1, 2, 3.3);
+ BOOST_TEST((!boost::fusion::all(t, boost::lambda::_1 == 1)));
+ BOOST_TEST((!boost::fusion::all(t, boost::lambda::_1 < 3)));
+ }
+
+ {
+ typedef boost::mpl::vector_c<int, 1> mpl_vec;
+ // We cannot use lambda here as mpl vec iterators return
+ // rvalues, and lambda needs lvalues.
+ BOOST_TEST(boost::fusion::all(mpl_vec(), search_for(1)));
+ BOOST_TEST(!boost::fusion::all(mpl_vec(), search_for(2)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/any.cpp b/src/boost/libs/fusion/test/algorithm/any.cpp
new file mode 100644
index 000000000..da0aa7933
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/any.cpp
@@ -0,0 +1,57 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2005 Eric Niebler
+ Copyright (c) Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/algorithm/query/any.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/mpl/vector_c.hpp>
+
+namespace
+{
+ struct search_for
+ {
+ explicit search_for(int in_search)
+ : search(in_search)
+ {}
+
+ template<typename T>
+ bool operator()(T const& v) const
+ {
+ return v == search;
+ }
+
+ int search;
+ };
+}
+
+int
+main()
+{
+ {
+ boost::fusion::vector<int, short, double> t(1, 2, 3.3);
+ BOOST_TEST(boost::fusion::any(t, boost::lambda::_1 == 2));
+ }
+
+ {
+ boost::fusion::vector<int, short, double> t(1, 2, 3.3);
+ BOOST_TEST(!boost::fusion::any(t, boost::lambda::_1 == 3));
+ }
+
+ {
+ typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
+ // We cannot use lambda here as mpl vec iterators return
+ // rvalues, and lambda needs lvalues.
+ BOOST_TEST(boost::fusion::any(mpl_vec(), search_for(2)));
+ BOOST_TEST(!boost::fusion::any(mpl_vec(), search_for(4)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/clear.cpp b/src/boost/libs/fusion/test/algorithm/clear.cpp
new file mode 100644
index 000000000..f90f5c0a6
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/clear.cpp
@@ -0,0 +1,45 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/transformation/clear.hpp>
+#include <boost/mpl/vector_c.hpp>
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing pop_back
+
+ {
+ char const* s = "Ruby";
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type t1(1, 'x', 3.3, s);
+
+ {
+ std::cout << clear(t1) << std::endl;
+ BOOST_TEST((clear(t1) == make_vector()));
+ }
+ }
+
+ {
+ typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
+ std::cout << boost::fusion::clear(mpl_vec()) << std::endl;
+ BOOST_TEST((boost::fusion::clear(mpl_vec()) == make_vector()));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/copy.cpp b/src/boost/libs/fusion/test/algorithm/copy.cpp
new file mode 100644
index 000000000..330caca62
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/copy.cpp
@@ -0,0 +1,26 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/container/list/list.hpp>
+#include <boost/fusion/sequence/comparison.hpp>
+#include <boost/fusion/algorithm/auxiliary/copy.hpp>
+
+int
+main()
+{
+ {
+ boost::fusion::vector<int, short, double> v(1, 2, 3);
+ boost::fusion::list<int, short, double> l;
+
+ boost::fusion::copy(v, l);
+ BOOST_TEST(v == l);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/count.cpp b/src/boost/libs/fusion/test/algorithm/count.cpp
new file mode 100644
index 000000000..13aaad1a6
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/count.cpp
@@ -0,0 +1,41 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2005 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/algorithm/query/count.hpp>
+#include <boost/mpl/vector_c.hpp>
+#include <string>
+
+int
+main()
+{
+ {
+ boost::fusion::vector<int, short, double> t(1, 1, 1);
+ BOOST_TEST(boost::fusion::count(t, 1) == 3);
+ }
+
+ {
+ boost::fusion::vector<int, short, double> t(1, 2, 3.3);
+ BOOST_TEST(boost::fusion::count(t, 3) == 0);
+ }
+
+ {
+ boost::fusion::vector<int, std::string, double> t(4, "hello", 4);
+ BOOST_TEST(boost::fusion::count(t, "hello") == 1);
+ }
+
+ {
+ typedef boost::mpl::vector_c<int, 1, 2, 2, 2, 3, 3> mpl_vec;
+ BOOST_TEST(boost::fusion::count(mpl_vec(), 2) == 3);
+ BOOST_TEST(boost::fusion::count(mpl_vec(), 3) == 2);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/count_if.cpp b/src/boost/libs/fusion/test/algorithm/count_if.cpp
new file mode 100644
index 000000000..7555f6fcb
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/count_if.cpp
@@ -0,0 +1,46 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2005 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/algorithm/query/count_if.hpp>
+#include <boost/mpl/vector_c.hpp>
+#include <functional>
+
+template <typename F> struct bind1st;
+template <template <typename> class F, typename T>
+struct bind1st<F<T> > : public F<T>
+{
+ T n;
+ bind1st(T n) : n(n) { }
+ bool operator()(T v) const { return F<T>::operator()(n, v); }
+};
+
+int
+main()
+{
+ {
+ boost::fusion::vector<int, short, double> t(1, 2, 3.3);
+ BOOST_TEST(boost::fusion::count_if(t, bind1st<std::equal_to<double> >(2)) == 1);
+ }
+
+ {
+ boost::fusion::vector<int, short, double> t(1, 2, 3.3);
+ BOOST_TEST(boost::fusion::count_if(t, bind1st<std::equal_to<double> >(3)) == 0);
+ }
+
+ {
+ typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
+ // Cannot use lambda here as mpl iterators return rvalues and lambda needs lvalues
+ BOOST_TEST(boost::fusion::count_if(mpl_vec(), bind1st<std::greater_equal<int> >(2)) == 2);
+ BOOST_TEST(boost::fusion::count_if(mpl_vec(), bind1st<std::less<int> >(2)) == 1);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/erase.cpp b/src/boost/libs/fusion/test/algorithm/erase.cpp
new file mode 100644
index 000000000..f376ba2a5
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/erase.cpp
@@ -0,0 +1,63 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/container/vector/vector_iterator.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/transformation/erase.hpp>
+#include <boost/mpl/vector_c.hpp>
+#include <boost/mpl/begin_end.hpp>
+#include <boost/mpl/advance.hpp>
+#include <boost/mpl/int.hpp>
+
+int
+main()
+{
+ using namespace boost::fusion;
+ using boost::mpl::vector_c;
+ using boost::mpl::begin;
+ using boost::mpl::advance;
+ using boost::mpl::int_;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing erase
+
+ {
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type t1(1, 'x', 3.3, "Ruby");
+ vector_iterator<vector_type, 2> pos(t1);
+
+ std::cout << erase(t1, pos) << std::endl;
+ BOOST_TEST((erase(t1, pos) == make_vector(1, 'x', std::string("Ruby"))));
+ BOOST_TEST((erase(t1, end(t1)) == make_vector(1, 'x', 3.3, std::string("Ruby"))));
+ }
+
+ {
+ typedef vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
+ typedef boost::mpl::begin<mpl_vec>::type mpl_vec_begin;
+ typedef boost::mpl::advance<mpl_vec_begin, int_<3> >::type mpl_vec_at3;
+ typedef boost::mpl::next<mpl_vec_begin>::type n1;
+ typedef boost::mpl::next<n1>::type n2;
+ typedef boost::mpl::next<n2>::type n3;
+
+ BOOST_STATIC_ASSERT((boost::is_same<mpl_vec_at3, n3>::value));
+
+
+ std::cout << erase(mpl_vec(), mpl_vec_at3()) << std::endl;
+ BOOST_TEST((erase(mpl_vec(), mpl_vec_at3())
+ == make_vector(1, 2, 3, 5)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/erase_key.cpp b/src/boost/libs/fusion/test/algorithm/erase_key.cpp
new file mode 100644
index 000000000..34f69248c
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/erase_key.cpp
@@ -0,0 +1,74 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/set/set.hpp>
+#include <boost/fusion/container/generation/make_set.hpp>
+#include <boost/fusion/container/map/map.hpp>
+#include <boost/fusion/container/generation/make_map.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/container/vector/convert.hpp>
+#include <boost/fusion/container/set/convert.hpp>
+#include <boost/fusion/container/map/convert.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/sequence/intrinsic/size.hpp>
+#include <boost/fusion/iterator/deref.hpp>
+#include <boost/fusion/algorithm/transformation/erase_key.hpp>
+#include <boost/fusion/algorithm/query/find.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/support/pair.hpp>
+#include <boost/static_assert.hpp>
+#include <iostream>
+#include <string>
+
+template <typename Set>
+void test_set(Set const& set)
+{
+ using namespace boost::fusion;
+ std::cout << set << std::endl;
+
+ BOOST_STATIC_ASSERT(boost::fusion::result_of::size<Set>::value == 3);
+ BOOST_TEST((*find<int>(set) == 1));
+ BOOST_TEST((*find<double>(set) == 1.5));
+ BOOST_TEST((*find<std::string>(set) == "hello"));
+}
+
+typedef boost::mpl::int_<1> _1;
+typedef boost::mpl::int_<2> _2;
+typedef boost::mpl::int_<3> _3;
+typedef boost::mpl::int_<4> _4;
+
+template <typename Map>
+void test_map(Map const& map)
+{
+ using namespace boost::fusion;
+ std::cout << map << std::endl;
+
+ BOOST_STATIC_ASSERT(boost::fusion::result_of::size<Map>::value == 3);
+ BOOST_TEST(((*find<_1>(map)).second == 1));
+ BOOST_TEST(((*find<_3>(map)).second == 1.5));
+ BOOST_TEST(((*find<_4>(map)).second == std::string("hello")));
+}
+
+int
+main()
+{
+ using namespace boost::fusion;
+ using namespace boost;
+ using namespace std;
+ using boost::fusion::pair;
+ using boost::fusion::make_pair;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+ test_set(erase_key<char>(make_set(1, 'x', 1.5, std::string("hello"))));
+ test_map(erase_key<_2>(make_map<_1, _2, _3, _4>(1, 'x', 1.5, "hello")));
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/filter.cpp b/src/boost/libs/fusion/test/algorithm/filter.cpp
new file mode 100644
index 000000000..e762e4322
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/filter.cpp
@@ -0,0 +1,43 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2005-2006 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/algorithm/transformation/filter.hpp>
+#include <boost/mpl/vector.hpp>
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+ typedef boost::fusion::vector<char,double,char> vector_type;
+ vector_type t('a', 6.6, 'b');
+
+ {
+ std::cout << filter<char>(t) << std::endl;
+ BOOST_TEST((filter<char>(t)
+ == make_vector('a', 'b')));
+ }
+
+ {
+ typedef boost::mpl::vector<char,double,char> mpl_vec;
+ BOOST_TEST((filter<char>(mpl_vec())
+ == make_vector('\0', '\0')));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/filter_if.cpp b/src/boost/libs/fusion/test/algorithm/filter_if.cpp
new file mode 100644
index 000000000..830813de6
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/filter_if.cpp
@@ -0,0 +1,77 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/algorithm/transformation/filter_if.hpp>
+#include <boost/type_traits/is_class.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/not.hpp>
+
+struct X
+{
+ operator char const*() const
+ {
+ return "<X-object>";
+ }
+};
+
+struct Y
+{
+ operator char const*() const
+ {
+ return "<Y-object>";
+ }
+};
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ using boost::mpl::_;
+ using boost::mpl::not_;
+ using boost::is_class;
+ using boost::is_same;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing filter_if
+
+ X x; Y y;
+ typedef boost::fusion::vector<Y, char, long, X, bool, double> vector_type;
+ vector_type t(y, '@', 987654, x, true, 6.6);
+
+ {
+ std::cout << filter_if<not_<is_class<_> > >(t) << std::endl;
+ BOOST_TEST((filter_if<not_<is_class<_> > >(t)
+ == make_vector('@', 987654, true, 6.6)));
+ }
+
+ {
+ std::cout << filter_if<is_class<_> >(t) << std::endl;
+ BOOST_TEST((filter_if<is_class<_> >(t)
+ == make_vector(y, x)));
+ }
+
+ {
+ typedef boost::mpl::vector<Y, char, long, X, bool> mpl_vec;
+ BOOST_TEST((filter_if<not_<is_class<_> > >(mpl_vec())
+ == make_vector(char(), long(), bool())));
+ BOOST_TEST((filter_if<is_class<_> >(mpl_vec())
+ == make_vector(y, x)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/find.cpp b/src/boost/libs/fusion/test/algorithm/find.cpp
new file mode 100644
index 000000000..83a86f1d9
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/find.cpp
@@ -0,0 +1,79 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/container/set/set.hpp>
+#include <boost/fusion/container/map/map.hpp>
+#include <boost/fusion/algorithm/query/find.hpp>
+#include <boost/fusion/iterator/deref.hpp>
+#include <boost/mpl/vector.hpp>
+#include <string>
+
+struct X
+{
+ operator int() const
+ {
+ return 12345;
+ }
+};
+int
+main()
+{
+ using namespace boost::fusion;
+ using boost::mpl::identity;
+
+ {
+ typedef vector<int, char, int, double> seq_type;
+ seq_type seq(12345, 'x', 678910, 3.36);
+
+ std::cout << *boost::fusion::find<char>(seq) << std::endl;
+ BOOST_TEST(*boost::fusion::find<char>(seq) == 'x');
+
+ std::cout << *boost::fusion::find<int>(seq) << std::endl;
+ BOOST_TEST(*boost::fusion::find<int>(seq) == 12345);
+
+ std::cout << *boost::fusion::find<double>(seq) << std::endl;
+ BOOST_TEST(*boost::fusion::find<double>(seq) == 3.36);
+
+ BOOST_TEST(boost::fusion::find<bool>(seq) == boost::fusion::end(seq));
+ }
+
+ {
+ typedef set<int, char, double> seq_type;
+ seq_type seq(12345, 'x', 3.36);
+ std::cout << *boost::fusion::find<char>(seq) << std::endl;
+ BOOST_TEST(*boost::fusion::find<char>(seq) == 'x');
+ BOOST_TEST(boost::fusion::find<bool>(seq) == boost::fusion::end(seq));
+ }
+
+ {
+ typedef map<
+ pair<int, char>
+ , pair<double, std::string> >
+ map_type;
+
+ map_type seq(
+ make_pair<int>('X')
+ , make_pair<double>("Men"));
+
+ std::cout << *boost::fusion::find<int>(seq) << std::endl;
+ std::cout << *boost::fusion::find<double>(seq) << std::endl;
+ BOOST_TEST((*boost::fusion::find<int>(seq)).second == 'X');
+ BOOST_TEST((*boost::fusion::find<double>(seq)).second == "Men");
+ BOOST_TEST(boost::fusion::find<bool>(seq) == boost::fusion::end(seq));
+ }
+
+ {
+ typedef boost::mpl::vector<int, char, X, double> mpl_vec;
+ BOOST_TEST((*boost::fusion::find<X>(mpl_vec()) == 12345));
+ BOOST_TEST(boost::fusion::find<bool>(mpl_vec()) == boost::fusion::end(mpl_vec()));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/find_if.cpp b/src/boost/libs/fusion/test/algorithm/find_if.cpp
new file mode 100644
index 000000000..c4dfafa28
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/find_if.cpp
@@ -0,0 +1,69 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/algorithm/query/find_if.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/vector_c.hpp>
+#include <boost/mpl/less.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+struct X
+{
+ operator int() const
+ {
+ return 12345;
+ }
+};
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ {
+ using boost::is_same;
+ using boost::mpl::_;
+
+ typedef vector<int, char, int, double> vector_type;
+ vector_type v(12345, 'x', 678910, 3.36);
+
+ std::cout << *find_if<is_same<_, char> >(v) << std::endl;
+ BOOST_TEST((*find_if<is_same<_, char> >(v) == 'x'));
+
+ std::cout << *find_if<is_same<_, int> >(v) << std::endl;
+ BOOST_TEST((*find_if<is_same<_, int> >(v) == 12345));
+
+ std::cout << *find_if<is_same<_, double> >(v) << std::endl;
+ BOOST_TEST((*find_if<is_same<_, double> >(v) == 3.36));
+ }
+
+ {
+ using boost::mpl::vector;
+ using boost::is_same;
+ using boost::mpl::_;
+
+ typedef vector<int, char, X, double> mpl_vec;
+ BOOST_TEST((*find_if<is_same<_, X> >(mpl_vec()) == 12345));
+ }
+
+ {
+ using boost::mpl::vector_c;
+ using boost::mpl::less;
+ using boost::mpl::int_;
+ using boost::is_same;
+ using boost::mpl::_;
+
+ typedef vector_c<int, 1, 2, 3, 4> mpl_vec;
+ BOOST_TEST((*find_if<less<_, int_<3> > >(mpl_vec()) == 1));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/flatten.cpp b/src/boost/libs/fusion/test/algorithm/flatten.cpp
new file mode 100644
index 000000000..ddc71006f
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/flatten.cpp
@@ -0,0 +1,57 @@
+/*==============================================================================
+ Copyright (c) 2013 Jamboree
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/sequence/intrinsic/begin.hpp>
+#include <boost/fusion/sequence/intrinsic/end.hpp>
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+#include <boost/fusion/sequence/intrinsic/size.hpp>
+#include <boost/fusion/iterator/advance.hpp>
+#include <boost/fusion/iterator/deref.hpp>
+#include <boost/fusion/iterator/distance.hpp>
+#include <boost/fusion/algorithm/auxiliary/copy.hpp>
+#include <boost/fusion/algorithm/transformation/flatten.hpp>
+
+
+int main()
+{
+ using namespace boost::fusion;
+
+ {
+ typedef vector<int, int, vector<int, int>, int> sequence_type;
+ sequence_type seq(1, 2, make_vector(3, 4), 5);
+
+ BOOST_TEST((boost::fusion::size(flatten(seq)) == 5));
+ }
+
+ {
+ typedef vector<int, int, vector<int, int>, int> sequence_type;
+ sequence_type seq(1, 2, make_vector(3, 4), 5);
+ std::cout << flatten(seq) << std::endl;
+ BOOST_TEST((flatten(seq) == make_vector(1, 2, 3, 4, 5)));
+ }
+
+ {
+ std::cout << flatten(make_vector(1, 2, make_vector(3, 4), 5)) << std::endl;
+ BOOST_TEST((flatten(make_vector(1, 2, make_vector(3, 4), 5)) == make_vector(1, 2, 3, 4, 5)));
+ }
+
+ {
+ typedef vector<int, int, vector<int, int>, int> sequence_type;
+ sequence_type seq;
+ result_of::flatten<sequence_type>::type flat(flatten(seq));
+ copy(make_vector(1, 2, 3, 4, 5), flat);
+ std::cout << seq << std::endl;
+ BOOST_TEST((seq == make_vector(1, 2, make_vector(3, 4), 5)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/fold.cpp b/src/boost/libs/fusion/test/algorithm/fold.cpp
new file mode 100644
index 000000000..c441ceaf0
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/fold.cpp
@@ -0,0 +1,257 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2007 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/iteration/fold.hpp>
+#include <boost/fusion/algorithm/iteration/accumulate.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/next.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/vector.hpp>
+
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/is_reference.hpp>
+
+#include <string>
+
+using boost::mpl::if_;
+using boost::mpl::int_;
+using boost::is_same;
+
+struct add_ints_only
+{
+ template<typename T>
+ struct result;
+
+ template <typename State, typename T>
+ struct result<add_ints_only(State, T)>
+ {
+ typedef typename boost::remove_const<
+ typename boost::remove_reference<State>::type>::type type;
+ };
+
+ template <typename State, typename T>
+ State
+ operator()(State const& state, T const& /*x*/) const
+ {
+ return state;
+ }
+
+ int
+ operator()(int state, int x) const
+ {
+ return x + state;
+ }
+};
+
+struct count_ints
+{
+ template<typename T>
+ struct result;
+
+ template <typename CountT, typename T>
+ struct result<count_ints(CountT, T)>
+ {
+ typedef typename boost::remove_const<
+ typename boost::remove_reference<CountT>::type>::type state;
+ typedef typename boost::remove_const<
+ typename boost::remove_reference<T>::type>::type elem;
+
+ typedef typename
+ if_<
+ is_same<elem, int>
+ , typename boost::mpl::next<state>::type
+ , state
+ >::type
+ type;
+ };
+
+ template <typename CountT, typename T>
+ typename result<count_ints(CountT, T)>::type
+ operator()(CountT const&, T const&) const
+ {
+ typedef typename result<count_ints(CountT, T)>::type result_;
+ return result_();
+ }
+};
+
+struct appender
+{
+ typedef std::string result_type;
+
+ std::string operator()(std::string const& str, char c) const
+ {
+ return str + c;
+ }
+};
+
+struct lvalue_adder
+{
+ template<typename Sig>
+ struct result;
+
+ template<typename T0, typename T1>
+ struct result<lvalue_adder(T0, T1&)>
+ {
+ // Second argument still needs to support rvalues - see definition of fusion::fold
+ typedef T1 type;
+ };
+
+ template<typename T0, typename T1>
+ T1 operator()(T0 const& lhs, T1& rhs) const
+ {
+ return lhs + rhs;
+ }
+};
+
+int add(int lhs, int rhs)
+{
+ return lhs + rhs;
+}
+
+struct functor
+{
+ template<typename T>
+ int
+ operator() (int hitherho, T const& cur) const
+ {
+ return int(hitherho + cur);
+ }
+};
+
+struct visitor
+{
+ typedef int result_type;
+
+ int operator()(int sum, long&)
+ {
+ return sum;
+ }
+};
+
+int
+main()
+{
+ using namespace boost::fusion;
+ namespace fusion = boost::fusion;
+
+ {
+ typedef vector<int, char, int, double> vector_type;
+ vector_type v(12345, 'x', 678910, 3.36);
+ int result = fold(v, 0, add_ints_only());
+ std::cout << result << std::endl;
+ BOOST_TEST(result == 12345+678910);
+ }
+
+ {
+ typedef vector<int> vector_type;
+ vector_type v(12345);
+
+ int n = fusion::fold(v, int_<0>(), count_ints());
+ std::cout << n << std::endl;
+ BOOST_TEST(n == 1);
+ }
+
+ {
+ typedef vector<int, char, int, double, int> vector_type;
+ vector_type v(12345, 'x', 678910, 3.36, 8756);
+
+ int n = fusion::fold(v, int_<0>(), count_ints());
+ std::cout << n << std::endl;
+ BOOST_TEST(n == 3);
+ }
+
+ {
+ typedef boost::mpl::vector<int, char, int, double, int> mpl_vec;
+ int n = fusion::fold(mpl_vec(), int_<0>(), count_ints());
+ std::cout << n << std::endl;
+ BOOST_TEST(n == 3);
+ }
+
+ {
+ BOOST_TEST(fusion::fold(fusion::make_vector('a','b','c','d','e'), std::string(""), appender())
+ == "abcde");
+ }
+
+ {
+ vector<int, int> vec(1,2);
+ BOOST_TEST(fusion::fold(vec, 0, lvalue_adder()) == 3);
+ }
+
+ {
+ vector<int, int> vec(1,2);
+ BOOST_TEST(fusion::fold(vec, 0, add) == 3);
+ }
+
+ {
+ typedef vector<int, char, int, double> vector_type;
+ vector_type v(12345, 'x', 678910, 3.36);
+ int result = accumulate(v, 0, add_ints_only());
+ std::cout << result << std::endl;
+ BOOST_TEST(result == 12345+678910);
+ }
+
+ {
+ typedef vector<int> vector_type;
+ vector_type v(12345);
+
+ int n = fusion::accumulate(v, int_<0>(), count_ints());
+ std::cout << n << std::endl;
+ BOOST_TEST(n == 1);
+ }
+
+ {
+ typedef vector<int, char, int, double, int> vector_type;
+ vector_type v(12345, 'x', 678910, 3.36, 8756);
+
+ int n = fusion::accumulate(v, int_<0>(), count_ints());
+ std::cout << n << std::endl;
+ BOOST_TEST(n == 3);
+ }
+
+ {
+ typedef boost::mpl::vector<int, char, int, double, int> mpl_vec;
+ int n = fusion::accumulate(mpl_vec(), int_<0>(), count_ints());
+ std::cout << n << std::endl;
+ BOOST_TEST(n == 3);
+ }
+
+ {
+ BOOST_TEST(fusion::accumulate(fusion::make_vector('a','b','c','d','e'), std::string(""), appender())
+ == "abcde");
+ }
+
+ {
+ vector<int, int> vec(1,2);
+ BOOST_TEST(fusion::accumulate(vec, 0, add) == 3);
+ }
+
+ {
+#if defined(BOOST_RESULT_OF_USE_DECLTYPE)
+ {
+ boost::fusion::vector<int, double, long> container{1, 2, 3};
+ functor f;
+ boost::fusion::fold(container, 0, f);
+ }
+#endif
+
+ {
+ boost::fusion::vector<long> vec;
+ visitor v;
+ boost::fusion::fold(vec, 0, v);
+ }
+ }
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/fusion/test/algorithm/fold.hpp b/src/boost/libs/fusion/test/algorithm/fold.hpp
new file mode 100644
index 000000000..997623ea8
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/fold.hpp
@@ -0,0 +1,212 @@
+/*=============================================================================
+ Copyright (c) 2010 Christopher Schmidt
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#include <boost/config.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/sequence.hpp>
+#include <boost/fusion/iterator.hpp>
+#include <boost/fusion/algorithm/transformation/reverse.hpp>
+#include <boost/fusion/algorithm/iteration/fold.hpp>
+#include <boost/fusion/algorithm/iteration/reverse_fold.hpp>
+#include <boost/fusion/algorithm/iteration/iter_fold.hpp>
+#include <boost/fusion/algorithm/iteration/reverse_iter_fold.hpp>
+#include <boost/fusion/container/vector/convert.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/support/pair.hpp>
+#include <boost/fusion/mpl.hpp>
+#include <boost/mpl/transform.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/back.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/for_each.hpp>
+#include <boost/mpl/range_c.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/back_inserter.hpp>
+#include <boost/mpl/always.hpp>
+#include <boost/mpl/copy.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <iostream>
+
+namespace mpl=boost::mpl;
+namespace fusion=boost::fusion;
+
+#ifdef BOOST_FUSION_TEST_REVERSE_FOLD
+# ifdef BOOST_FUSION_TEST_ITER_FOLD
+# define BOOST_FUSION_TEST_FOLD_NAME reverse_iter_fold
+# else
+# define BOOST_FUSION_TEST_FOLD_NAME reverse_fold
+# endif
+#else
+# ifdef BOOST_FUSION_TEST_ITER_FOLD
+# define BOOST_FUSION_TEST_FOLD_NAME iter_fold
+# else
+# define BOOST_FUSION_TEST_FOLD_NAME fold
+# endif
+#endif
+
+struct sum
+{
+ template<typename Sig>
+ struct result;
+
+ template<typename Self, typename State, typename T>
+ struct result<Self(State,T)>
+ : boost::fusion::result_of::make_pair<
+ mpl::int_<
+ boost::remove_reference<
+ State
+ >::type::first_type::value+1
+ >
+ , int
+ >
+ {
+ BOOST_MPL_ASSERT((typename boost::is_reference<State>::type));
+ BOOST_MPL_ASSERT((typename boost::is_reference<T>::type));
+ };
+
+#ifdef BOOST_FUSION_TEST_ITER_FOLD
+ template<typename State, typename It>
+ typename result<sum const&(State const&,It const&)>::type
+ operator()(State const& state, It const& it)const
+ {
+ static const int n=State::first_type::value;
+ return fusion::make_pair<mpl::int_<n+1> >(
+ state.second+fusion::deref(it)*n);
+ }
+#else
+ template<typename State>
+ typename result<sum const&(State const&, int const&)>::type
+ operator()(State const& state, int const& e)const
+ {
+ static const int n=State::first_type::value;
+ return fusion::make_pair<mpl::int_<n+1> >(state.second+e*n);
+ }
+#endif
+};
+
+struct meta_sum
+{
+ template<typename Sig>
+ struct result;
+
+ template<typename Self, typename State, typename T>
+ struct result<Self(State,T)>
+ {
+ BOOST_MPL_ASSERT((typename boost::is_reference<State>::type));
+ BOOST_MPL_ASSERT((typename boost::is_reference<T>::type));
+
+ typedef typename boost::remove_reference<State>::type state;
+ static const int n=mpl::front<state>::type::value;
+
+#ifdef BOOST_FUSION_TEST_ITER_FOLD
+ typedef typename
+ boost::fusion::result_of::value_of<
+ typename boost::remove_reference<T>::type
+ >::type
+ t;
+#else
+ typedef typename boost::remove_reference<T>::type t;
+#endif
+
+ typedef
+ mpl::vector<
+ mpl::int_<n+1>
+ , mpl::int_<
+ mpl::back<state>::type::value+t::value*n
+ >
+ >
+ type;
+ };
+
+ template<typename State, typename T>
+ typename result<meta_sum const&(State const&,T const&)>::type
+ operator()(State const&, T const&)const;
+};
+
+struct fold_test_n
+{
+ template<typename I>
+ void
+ operator()(I)const
+ {
+ static const int n=I::value;
+ typedef mpl::range_c<int, 0, n> range;
+
+ static const int squares_sum=n*(n+1)*(2*n+1)/6;
+
+ {
+ mpl::range_c<int, 1, n+1> init_range;
+ typename boost::fusion::result_of::as_vector<
+ typename mpl::transform<
+ range
+ , mpl::always<int>
+ , mpl::back_inserter<mpl::vector<> >
+ >::type
+ >::type vec(
+#ifdef BOOST_FUSION_TEST_REVERSE_FOLD
+ fusion::reverse(init_range)
+#else
+ init_range
+#endif
+ );
+
+ int result=BOOST_FUSION_TEST_FOLD_NAME(
+ vec,
+ fusion::make_pair<mpl::int_<1> >(0),
+ sum()).second;
+ std::cout << n << ": " << result << std::endl;
+ BOOST_TEST(result==squares_sum);
+ }
+
+ {
+ typedef typename
+#ifdef BOOST_FUSION_TEST_REVERSE_FOLD
+ boost::fusion::result_of::as_vector<
+ typename mpl::copy<
+ mpl::range_c<int, 1, n+1>
+ , mpl::front_inserter<fusion::vector<> >
+ >::type
+ >::type
+#else
+ boost::fusion::result_of::as_vector<mpl::range_c<int, 1, n+1> >::type
+#endif
+ vec;
+
+ typedef
+ boost::is_same<
+ typename boost::fusion::result_of::BOOST_FUSION_TEST_FOLD_NAME<
+ vec
+ , mpl::vector<mpl::int_<1>, mpl::int_<0> >
+ , meta_sum
+ >::type
+ , typename mpl::if_c<
+ !n
+ , mpl::vector<mpl::int_<1>, mpl::int_<0> >&
+ , mpl::vector<mpl::int_<n+1>, mpl::int_<squares_sum> >
+ >::type
+ >
+ result_test;
+
+ BOOST_MPL_ASSERT((result_test));
+ }
+ }
+};
+
+int
+main()
+{
+ mpl::for_each<mpl::range_c<int, 0, 10> >(fold_test_n());
+
+ return boost::report_errors();
+}
+
+#undef BOOST_FUSION_TEST_FOLD_NAME
+
diff --git a/src/boost/libs/fusion/test/algorithm/for_each.cpp b/src/boost/libs/fusion/test/algorithm/for_each.cpp
new file mode 100644
index 000000000..982cb3a12
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/for_each.cpp
@@ -0,0 +1,83 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2018 Kohei Takahashi
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/core/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#include <boost/mpl/vector_c.hpp>
+
+struct print
+{
+ template <typename T>
+ void operator()(T const& v) const
+ {
+ std::cout << "[ " << v << " ] ";
+ }
+};
+
+struct increment
+{
+ template <typename T>
+ void operator()(T& v) const
+ {
+ ++v;
+ }
+};
+
+struct mutable_increment : increment
+{
+ template <typename T>
+ void operator()(T& v)
+ {
+ return increment::operator()(v);
+ }
+};
+
+int
+main()
+{
+ using namespace boost::fusion;
+ using boost::mpl::vector_c;
+ namespace fusion = boost::fusion;
+
+ {
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type v(1, 'x', 3.3, "Ruby");
+ for_each(v, print());
+ std::cout << std::endl;
+ }
+
+ {
+ char const ruby[] = "Ruby";
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type v(1, 'x', 3.3, ruby);
+ for_each(v, increment());
+ BOOST_TEST_EQ(v, vector_type(2, 'y', 4.3, ruby + 1));
+ std::cout << v << std::endl;
+ }
+
+ {
+ char const ruby[] = "Ruby";
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type v(1, 'x', 3.3, ruby);
+ for_each(v, mutable_increment());
+ BOOST_TEST_EQ(v, vector_type(2, 'y', 4.3, ruby + 1));
+ std::cout << v << std::endl;
+ }
+
+ {
+ typedef vector_c<int, 2, 3, 4, 5, 6> mpl_vec;
+ fusion::for_each(mpl_vec(), print());
+ std::cout << std::endl;
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/insert.cpp b/src/boost/libs/fusion/test/algorithm/insert.cpp
new file mode 100644
index 000000000..a4239a8de
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/insert.cpp
@@ -0,0 +1,67 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/transformation/insert.hpp>
+#include <boost/mpl/vector_c.hpp>
+#include <boost/mpl/begin_end.hpp>
+#include <boost/mpl/advance.hpp>
+#include <boost/mpl/int.hpp>
+#include <string>
+
+int
+main()
+{
+ using namespace boost::fusion;
+ using boost::mpl::vector_c;
+ using boost::mpl::advance;
+ using boost::mpl::int_;
+ namespace fusion = boost::fusion;
+ namespace mpl = boost::mpl;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing insert
+
+ {
+ char const* s = "Ruby";
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type t1(1, 'x', 3.3, s);
+ vector_iterator<vector_type, 2> pos(t1);
+
+ std::cout << insert(t1, pos, 123456) << std::endl;
+ BOOST_TEST((insert(t1, pos, 123456)
+ == make_vector(1, 'x', 123456, 3.3, s)));
+
+ std::cout << insert(t1, end(t1), 123456) << std::endl;
+ BOOST_TEST((insert(t1, end(t1), 123456)
+ == make_vector(1, 'x', 3.3, s, 123456)));
+
+ std::cout << insert(t1, begin(t1), "glad") << std::endl;
+ BOOST_TEST((insert(t1, begin(t1), "glad")
+ == make_vector(std::string("glad"), 1, 'x', 3.3, s)));
+ }
+
+ {
+ typedef vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
+ typedef mpl::begin<mpl_vec>::type mpl_vec_begin;
+ typedef advance<mpl_vec_begin, int_<3> >::type mpl_vec_at3;
+
+ std::cout << fusion::insert(mpl_vec(), mpl_vec_at3(), int_<66>()) << std::endl;
+ BOOST_TEST((fusion::insert(mpl_vec(), mpl_vec_at3(), int_<66>())
+ == make_vector(1, 2, 3, 66, 4, 5)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/insert_range.cpp b/src/boost/libs/fusion/test/algorithm/insert_range.cpp
new file mode 100644
index 000000000..28a02219b
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/insert_range.cpp
@@ -0,0 +1,71 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/transformation/insert_range.hpp>
+#include <boost/mpl/vector_c.hpp>
+#include <boost/mpl/begin_end.hpp>
+#include <boost/mpl/advance.hpp>
+#include <boost/mpl/int.hpp>
+#include <string>
+
+int
+main()
+{
+ using namespace boost::fusion;
+ using boost::mpl::vector_c;
+ using boost::mpl::advance;
+ using boost::mpl::int_;
+ namespace fusion = boost::fusion;
+ namespace mpl = boost::mpl;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing insert_range
+
+ {
+ char const* s = "Ruby";
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type t1(1, 'x', 3.3, s);
+ vector_iterator<vector_type, 2> pos(t1);
+
+ typedef vector<int, char> vector_type2;
+ vector_type2 t2(999, 'z');
+
+ std::cout << insert_range(t1, pos, t2) << std::endl;
+ BOOST_TEST((insert_range(t1, pos, t2)
+ == make_vector(1, 'x', 999, 'z', 3.3, s)));
+
+ std::cout << insert_range(t1, end(t1), t2) << std::endl;
+ BOOST_TEST((insert_range(t1, end(t1), t2)
+ == make_vector(1, 'x', 3.3, s, 999, 'z')));
+
+ std::cout << insert_range(t1, begin(t1), t2) << std::endl;
+ BOOST_TEST((insert_range(t1, begin(t1), t2)
+ == make_vector(999, 'z', 1, 'x', 3.3, s)));
+ }
+
+ {
+ typedef vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
+ typedef mpl::begin<mpl_vec>::type mpl_vec_begin;
+ typedef advance<mpl_vec_begin, int_<3> >::type mpl_vec_at3;
+ typedef vector_c<int, -1, -2> mpl_vec2;
+
+ std::cout << fusion::insert_range(mpl_vec(), mpl_vec_at3(), mpl_vec2()) << std::endl;
+ BOOST_TEST((fusion::insert_range(mpl_vec(), mpl_vec_at3(), mpl_vec2())
+ == make_vector(1, 2, 3, -1, -2, 4, 5)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/iter_fold.cpp b/src/boost/libs/fusion/test/algorithm/iter_fold.cpp
new file mode 100644
index 000000000..b37f90db5
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/iter_fold.cpp
@@ -0,0 +1,10 @@
+/*=============================================================================
+ Copyright (c) 2010 Christopher Schmidt
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#define BOOST_FUSION_TEST_ITER_FOLD
+#include "fold.hpp"
+#undef BOOST_FUSION_TEST_ITER_FOLD
diff --git a/src/boost/libs/fusion/test/algorithm/join.cpp b/src/boost/libs/fusion/test/algorithm/join.cpp
new file mode 100644
index 000000000..c0de1896a
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/join.cpp
@@ -0,0 +1,28 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2006 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/algorithm/transformation/join.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/mpl/vector/vector10_c.hpp>
+
+int main()
+{
+ using namespace boost::fusion;
+ {
+ BOOST_TEST(join(make_vector(1,2), make_vector('a','b')) == make_vector(1,2,'a','b'));
+ }
+ {
+ typedef boost::mpl::vector2_c<int,1,2> vec1;
+ typedef boost::mpl::vector2_c<int,3,4> vec2;
+ BOOST_TEST(join(vec1(), vec2()) == make_vector(1,2,3,4));
+
+ }
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/fusion/test/algorithm/move.cpp b/src/boost/libs/fusion/test/algorithm/move.cpp
new file mode 100644
index 000000000..d2f854030
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/move.cpp
@@ -0,0 +1,27 @@
+/*=============================================================================
+ Copyright (c) 2014,2018 Kohei Takahashi
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/core/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/container/list/list.hpp>
+#include <boost/fusion/sequence/comparison.hpp>
+#include <boost/fusion/algorithm/auxiliary/move.hpp>
+#include <utility>
+
+int main()
+{
+ {
+ boost::fusion::vector<int, short, double> v(1, 2, 3);
+ boost::fusion::list<int, short, double> l1 = v;
+ boost::fusion::list<int, short, double> l2;
+
+ boost::fusion::move(std::move(v), l2);
+ BOOST_TEST(l1 == l2);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/none.cpp b/src/boost/libs/fusion/test/algorithm/none.cpp
new file mode 100644
index 000000000..83dfa7528
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/none.cpp
@@ -0,0 +1,58 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2007 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/algorithm/query/none.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/mpl/vector_c.hpp>
+
+namespace
+{
+ struct search_for
+ {
+ explicit search_for(int in_search)
+ : search(in_search)
+ {}
+
+ template<typename T>
+ bool operator()(T const& v) const
+ {
+ return v == search;
+ }
+
+ int search;
+ };
+}
+
+int
+main()
+{
+ {
+ boost::fusion::vector<int, short, double> t(1, 2, 3.3);
+ BOOST_TEST((boost::fusion::none(t, boost::lambda::_1 > 4)));
+ BOOST_TEST((boost::fusion::none(t, boost::lambda::_1 < 0)));
+ }
+
+ {
+ boost::fusion::vector<int, short, double> t(1, 2, 3.3);
+ BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 == 1)));
+ BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 < 3)));
+ }
+
+ {
+ typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
+ // We cannot use lambda here as mpl vec iterators return
+ // rvalues, and lambda needs lvalues.
+ BOOST_TEST(boost::fusion::none(mpl_vec(), search_for(4)));
+ BOOST_TEST(!boost::fusion::none(mpl_vec(), search_for(3)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/pop_back.cpp b/src/boost/libs/fusion/test/algorithm/pop_back.cpp
new file mode 100644
index 000000000..fcb5b75cf
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/pop_back.cpp
@@ -0,0 +1,105 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/container/list/list.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/container/generation/make_list.hpp>
+#include <boost/fusion/algorithm/transformation/pop_back.hpp>
+#include <boost/fusion/algorithm/transformation/push_back.hpp>
+#include <boost/fusion/algorithm/query/find.hpp>
+#include <boost/fusion/include/back.hpp>
+#include <boost/fusion/include/array.hpp>
+#include <boost/array.hpp>
+#include <boost/mpl/vector_c.hpp>
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing pop_back
+
+ {
+ char const* s = "Ruby";
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type t1(1, 'x', 3.3, s);
+
+ {
+ std::cout << pop_back(t1) << std::endl;
+ BOOST_TEST((pop_back(t1) == make_vector(1, 'x', 3.3)));
+ }
+ }
+
+ {
+ typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
+ std::cout << boost::fusion::pop_back(mpl_vec()) << std::endl;
+ BOOST_TEST((boost::fusion::pop_back(mpl_vec()) == make_vector(1, 2, 3, 4)));
+ }
+
+ {
+ list<int, int> l(1, 2);
+ std::cout << pop_back(l) << std::endl;
+ BOOST_TEST((pop_back(l) == make_list(1)));
+ }
+
+ { // make sure empty sequences are OK
+ list<int> l(1);
+ std::cout << pop_back(l) << std::endl;
+ BOOST_TEST((pop_back(l) == make_list()));
+ }
+
+ {
+ single_view<int> sv(1);
+ std::cout << pop_back(sv) << std::endl;
+
+ // Compile check only
+ (void)(begin(pop_back(sv)) == end(sv));
+ (void)(end(pop_back(sv)) == begin(sv));
+ }
+
+ // $$$ JDG: TODO add compile fail facility $$$
+ //~ { // compile fail check (Disabled for now)
+ //~ list<> l;
+ //~ std::cout << pop_back(l) << std::endl;
+ //~ }
+
+#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
+ {
+ auto vec = make_vector(1, 3.14, "hello");
+
+ // Compile check only
+ auto popv = pop_back(vec);
+ std::cout << popv << std::endl;
+
+ auto push = push_back(vec, 42);
+ auto pop = pop_back(vec);
+ auto i1 = find<int>(popv);
+ auto i2 = find<double>(pop);
+
+ (void)push;
+ BOOST_TEST(i1 != end(pop));
+ BOOST_TEST(i2 != end(pop));
+ BOOST_TEST(i1 != i2);
+ }
+#endif
+
+ {
+ boost::array<std::size_t, 2> a = {{ 10, 50 }};
+ BOOST_TEST(back(pop_back(a)) == 10);
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/pop_front.cpp b/src/boost/libs/fusion/test/algorithm/pop_front.cpp
new file mode 100644
index 000000000..df95b38c1
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/pop_front.cpp
@@ -0,0 +1,46 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/transformation/pop_front.hpp>
+#include <boost/mpl/vector_c.hpp>
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing pop_front
+
+ {
+ char const* s = "Ruby";
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type t1(1, 'x', 3.3, s);
+
+ {
+ std::cout << pop_front(t1) << std::endl;
+ BOOST_TEST((pop_front(t1) == make_vector('x', 3.3, s)));
+ }
+ }
+
+ {
+ typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
+ std::cout << boost::fusion::pop_front(mpl_vec()) << std::endl;
+ BOOST_TEST((boost::fusion::pop_front(mpl_vec()) == make_vector(2, 3, 4, 5)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/push_back.cpp b/src/boost/libs/fusion/test/algorithm/push_back.cpp
new file mode 100644
index 000000000..b53007fcf
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/push_back.cpp
@@ -0,0 +1,72 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/transformation/push_back.hpp>
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#include <boost/mpl/vector_c.hpp>
+#include <string>
+
+struct plus_one
+{
+ template <typename T>
+ void operator()(T& v) const
+ {
+ v += 1;
+ }
+};
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing push_back
+
+ {
+ char const* s = "Ruby";
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type t1(1, 'x', 3.3, s);
+
+ {
+ std::cout << push_back(t1, 123456) << std::endl;
+ BOOST_TEST((push_back(t1, 123456)
+ == make_vector(1, 'x', 3.3, s, 123456)));
+ }
+
+ {
+ std::cout << push_back(t1, "funny") << std::endl;
+ BOOST_TEST((push_back(t1, "funny")
+ == make_vector(1, 'x', 3.3, s, std::string("funny"))));
+ }
+
+ {
+ std::cout << push_back(t1, t1) << std::endl;
+ BOOST_TEST((push_back(t1, t1)
+ == make_vector(1, 'x', 3.3, s, t1)));
+ }
+ }
+
+ {
+ typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
+ std::cout << boost::fusion::push_back(mpl_vec(), boost::mpl::int_<6>()) << std::endl;
+ BOOST_TEST((boost::fusion::push_back(mpl_vec(), boost::mpl::int_<6>())
+ == make_vector(1, 2, 3, 4, 5, 6)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/push_front.cpp b/src/boost/libs/fusion/test/algorithm/push_front.cpp
new file mode 100644
index 000000000..8c63c5c3c
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/push_front.cpp
@@ -0,0 +1,55 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/transformation/push_front.hpp>
+#include <boost/mpl/vector_c.hpp>
+#include <string>
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing push_front
+
+ {
+ char const* s = "Ruby";
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type t1(1, 'x', 3.3, s);
+
+ {
+ std::cout << push_front(t1, 123456) << std::endl;
+ BOOST_TEST((push_front(t1, 123456)
+ == make_vector(123456, 1, 'x', 3.3, s)));
+ }
+
+ {
+ std::cout << push_front(t1, "lively") << std::endl;
+ BOOST_TEST((push_front(t1, "lively")
+ == make_vector(std::string("lively"), 1, 'x', 3.3, s)));
+ }
+ }
+
+ {
+ typedef boost::mpl::vector_c<int, 2, 3, 4, 5, 6> mpl_vec;
+ std::cout << boost::fusion::push_front(mpl_vec(), boost::mpl::int_<1>()) << std::endl;
+ BOOST_TEST((boost::fusion::push_front(mpl_vec(), boost::mpl::int_<1>())
+ == make_vector(1, 2, 3, 4, 5, 6)));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/remove.cpp b/src/boost/libs/fusion/test/algorithm/remove.cpp
new file mode 100644
index 000000000..76e0c737c
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/remove.cpp
@@ -0,0 +1,80 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/algorithm/transformation/remove.hpp>
+#include <boost/mpl/vector.hpp>
+
+struct X
+{
+ operator char const*() const
+ {
+ return "<X-object>";
+ }
+};
+
+struct Y
+{
+ operator char const*() const
+ {
+ return "<Y-object>";
+ }
+};
+
+int
+main()
+{
+ using namespace boost::fusion;
+ using boost::mpl::identity;
+ using boost::mpl::vector;
+ namespace fusion = boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing remove
+
+ X x; Y y;
+ typedef fusion::vector<Y, char, long, X, bool, double> vector_type;
+ vector_type t(y, '@', 987654, x, true, 6.6);
+
+ {
+ std::cout << fusion::remove<X>(t) << std::endl;
+ BOOST_TEST((fusion::remove<X>(t)
+ == make_vector(y, '@', 987654, true, 6.6)));
+ }
+
+ {
+ std::cout << fusion::remove<Y>(t) << std::endl;
+ BOOST_TEST((fusion::remove<Y>(t)
+ == make_vector('@', 987654, x, true, 6.6)));
+ }
+
+ {
+ std::cout << fusion::remove<long>(t) << std::endl;
+ BOOST_TEST((fusion::remove<long>(t)
+ == make_vector(y, '@', x, true, 6.6)));
+ }
+
+ {
+ typedef vector<Y, char, long, X, bool> mpl_vec;
+ BOOST_TEST((fusion::remove<X>(mpl_vec())
+ == vector<Y, char, long, bool>()));
+ BOOST_TEST((fusion::remove<Y>(mpl_vec())
+ == vector<char, long, X, bool>()));
+ BOOST_TEST((fusion::remove<long>(mpl_vec())
+ == vector<Y, char, X, bool>()));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/remove_if.cpp b/src/boost/libs/fusion/test/algorithm/remove_if.cpp
new file mode 100644
index 000000000..62313d3a5
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/remove_if.cpp
@@ -0,0 +1,78 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/algorithm/transformation/remove_if.hpp>
+#include <boost/type_traits/is_class.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/mpl/vector.hpp>
+
+struct X
+{
+ operator char const*() const
+ {
+ return "<X-object>";
+ }
+};
+
+struct Y
+{
+ operator char const*() const
+ {
+ return "<Y-object>";
+ }
+};
+
+int
+main()
+{
+ using namespace boost::fusion;
+ using boost::mpl::vector;
+ using boost::mpl::_;
+ using boost::mpl::not_;
+ using boost::is_class;
+ using boost::is_same;
+ namespace fusion = boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing remove_if
+
+ X x; Y y;
+ typedef fusion::vector<Y, char, long, X, bool, double> vector_type;
+ vector_type t(y, '@', 987654, x, true, 6.6);
+
+ {
+ std::cout << remove_if<not_<is_class<_> > >(t) << std::endl;
+ BOOST_TEST((remove_if<not_<is_class<_> > >(t)
+ == make_vector(y, x)));
+ }
+
+ {
+ std::cout << remove_if<is_class<_> >(t) << std::endl;
+ BOOST_TEST((remove_if<is_class<_> >(t)
+ == make_vector('@', 987654, true, 6.6)));
+ }
+
+ {
+ typedef vector<Y, char, long, X, bool> mpl_vec;
+ BOOST_TEST((remove_if<not_<is_class<_> > >(mpl_vec())
+ == vector<Y, X>()));
+ BOOST_TEST((remove_if<is_class<_> >(mpl_vec())
+ == vector<char, long, bool>()));
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/replace.cpp b/src/boost/libs/fusion/test/algorithm/replace.cpp
new file mode 100644
index 000000000..ddd651301
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/replace.cpp
@@ -0,0 +1,49 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/transformation/replace.hpp>
+#include <string>
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing replace
+
+ {
+ char const* s = "Ruby";
+ typedef vector<int, char, long, char const*> vector_type;
+ vector_type t1(1, 'x', 3, s);
+
+ {
+ std::cout << replace(t1, 'x', 'y') << std::endl;
+ BOOST_TEST((replace(t1, 'x', 'y')
+ == make_vector(1, 'y', 3, s)));
+ }
+
+ {
+ char const* s2 = "funny";
+ std::cout << replace(t1, s, s2) << std::endl;
+ BOOST_TEST((replace(t1, s, s2)
+ == make_vector(1, 'x', 3, s2)));
+ }
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/replace_if.cpp b/src/boost/libs/fusion/test/algorithm/replace_if.cpp
new file mode 100644
index 000000000..bad5905e1
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/replace_if.cpp
@@ -0,0 +1,52 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/transformation/replace_if.hpp>
+#include <string>
+
+struct gt3
+{
+ template <typename T>
+ bool operator()(T x) const
+ {
+ return x > 3;
+ }
+};
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing replace
+
+ {
+ char const* s = "Ruby";
+ typedef vector<int, short, double, long, char const*, float> vector_type;
+ vector_type t1(1, 2, 3.3, 4, s, 5.5f);
+
+ {
+ std::cout << replace_if(t1, gt3(), -456) << std::endl;
+ BOOST_TEST((replace_if(t1, gt3(), -456)
+ == make_vector(1, 2, -456, -456, s, -456)));
+ }
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/reverse.cpp b/src/boost/libs/fusion/test/algorithm/reverse.cpp
new file mode 100644
index 000000000..718d5b248
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/reverse.cpp
@@ -0,0 +1,49 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/algorithm/transformation/reverse.hpp>
+#include <boost/mpl/range_c.hpp>
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing the reverse_view
+
+ {
+ typedef boost::mpl::range_c<int, 5, 9> mpl_list1;
+ mpl_list1 sequence;
+
+ std::cout << reverse(sequence) << std::endl;
+ BOOST_TEST((reverse(sequence) == make_vector(8, 7, 6, 5)));
+ }
+
+ {
+ char const* s = "Hi Kim";
+ typedef vector<int, char, double, char const*> vector_type;
+ vector_type t(123, 'x', 3.36, s);
+
+ std::cout << reverse(t) << std::endl;
+ BOOST_TEST((reverse(t) == make_vector(s, 3.36, 'x', 123)));
+ std::cout << reverse(reverse(t)) << std::endl;
+ BOOST_TEST((reverse(reverse(t)) == t));
+ }
+
+ return boost::report_errors();
+}
+
+
diff --git a/src/boost/libs/fusion/test/algorithm/reverse_fold.cpp b/src/boost/libs/fusion/test/algorithm/reverse_fold.cpp
new file mode 100644
index 000000000..7742bca84
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/reverse_fold.cpp
@@ -0,0 +1,10 @@
+/*=============================================================================
+ Copyright (c) 2010 Christopher Schmidt
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#define BOOST_FUSION_TEST_REVERSE_FOLD
+#include "fold.hpp"
+#undef BOOST_FUSION_TEST_REVERSE_FOLD
diff --git a/src/boost/libs/fusion/test/algorithm/reverse_iter_fold.cpp b/src/boost/libs/fusion/test/algorithm/reverse_iter_fold.cpp
new file mode 100644
index 000000000..31e4cf265
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/reverse_iter_fold.cpp
@@ -0,0 +1,12 @@
+/*=============================================================================
+ Copyright (c) 2010 Christopher Schmidt
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+#define BOOST_FUSION_TEST_REVERSE_FOLD
+#define BOOST_FUSION_TEST_ITER_FOLD
+#include "fold.hpp"
+#undef BOOST_FUSION_TEST_ITER_FOLD
+#undef BOOST_FUSION_TEST_REVERSE_FOLD
diff --git a/src/boost/libs/fusion/test/algorithm/segmented_find.cpp b/src/boost/libs/fusion/test/algorithm/segmented_find.cpp
new file mode 100644
index 000000000..8ce0b6d55
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/segmented_find.cpp
@@ -0,0 +1,62 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2011 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/algorithm/query/find.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include "../sequence/tree.hpp"
+
+struct not_there {};
+
+template<typename Tree>
+void
+process_tree(Tree const &tree)
+{
+ using namespace boost;
+
+ typedef typename boost::fusion::result_of::find<Tree const, short>::type short_iter;
+ typedef typename boost::fusion::result_of::find<Tree const, float>::type float_iter;
+ typedef typename boost::fusion::result_of::find<Tree const, not_there>::type not_there_iter;
+
+ // find_if_s of a segmented data structure returns generic
+ // segmented iterators
+ short_iter si = fusion::find<short>(tree);
+ float_iter fi = fusion::find<float>(tree);
+
+ // they behave like ordinary Fusion iterators ...
+ BOOST_TEST((*si == short('d')));
+ BOOST_TEST((*fi == float(1)));
+
+ // Searching for something that's not there should return the end iterator.
+ not_there_iter nti = fusion::find<not_there>(tree);
+ BOOST_TEST((nti == fusion::end(tree)));
+}
+
+int
+main()
+{
+ using namespace boost::fusion;
+ process_tree(
+ make_tree(
+ make_vector(double(0),'B')
+ , make_tree(
+ make_vector(1,2,long(3))
+ , make_tree(make_vector('a','b','c'))
+ , make_tree(make_vector(short('d'),'e','f'))
+ )
+ , make_tree(
+ make_vector(4,5,6)
+ , make_tree(make_vector(float(1),'h','i'))
+ , make_tree(make_vector('j','k','l'))
+ )
+ )
+ );
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/segmented_find_if.cpp b/src/boost/libs/fusion/test/algorithm/segmented_find_if.cpp
new file mode 100644
index 000000000..98d963cff
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/segmented_find_if.cpp
@@ -0,0 +1,65 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2011 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/algorithm/query/find_if.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include "../sequence/tree.hpp"
+
+struct not_there {};
+
+template<typename Tree>
+void
+process_tree(Tree const &tree)
+{
+ using namespace boost;
+ using mpl::_;
+
+ typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,short> >::type short_iter;
+ typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,float> >::type float_iter;
+ typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,not_there> >::type not_there_iter;
+
+ // find_if of a segmented data structure returns generic
+ // segmented iterators
+ short_iter si = fusion::find_if<is_same<_,short> >(tree);
+ float_iter fi = fusion::find_if<is_same<_,float> >(tree);
+
+ // they behave like ordinary Fusion iterators ...
+ BOOST_TEST((*si == short('d')));
+ BOOST_TEST((*fi == float(1)));
+
+ // Searching for something that's not there should return the end iterator.
+ not_there_iter nti = fusion::find_if<is_same<_,not_there> >(tree);
+ BOOST_TEST((nti == fusion::end(tree)));
+}
+
+int
+main()
+{
+ using namespace boost::fusion;
+ process_tree(
+ make_tree(
+ make_vector(double(0),'B')
+ , make_tree(
+ make_vector(1,2,long(3))
+ , make_tree(make_vector('a','b','c'))
+ , make_tree(make_vector(short('d'),'e','f'))
+ )
+ , make_tree(
+ make_vector(4,5,6)
+ , make_tree(make_vector(float(1),'h','i'))
+ , make_tree(make_vector('j','k','l'))
+ )
+ )
+ );
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/segmented_fold.cpp b/src/boost/libs/fusion/test/algorithm/segmented_fold.cpp
new file mode 100644
index 000000000..af51ca89f
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/segmented_fold.cpp
@@ -0,0 +1,63 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2011 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <string>
+#include <sstream>
+#include <iostream>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/algorithm/iteration/fold.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include "../sequence/tree.hpp"
+
+struct write_string
+{
+ typedef std::ostream* result_type;
+
+ template<typename T>
+ std::ostream* operator()(std::ostream* sout, T const& t) const
+ {
+ return &(*sout << t << " ");
+ }
+};
+
+template<typename Tree>
+void
+process_tree(Tree const &tree)
+{
+ using namespace boost;
+
+ std::stringstream str;
+ fusion::fold(tree, &str, write_string());
+ std::string res = str.str();
+
+ BOOST_TEST_EQ(res, "a b c 1 2 3 100 e f 0 B 1 h i 4 5 6 j k l ");
+}
+
+int
+main()
+{
+ using namespace boost::fusion;
+ process_tree(
+ make_tree(
+ make_vector(double(0),'B')
+ , make_tree(
+ make_vector(1,2,long(3))
+ , make_tree(make_vector('a','b','c'))
+ , make_tree(make_vector(short('d'),'e','f'))
+ )
+ , make_tree(
+ make_vector(4,5,6)
+ , make_tree(make_vector(float(1),'h','i'))
+ , make_tree(make_vector('j','k','l'))
+ )
+ )
+ );
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/segmented_for_each.cpp b/src/boost/libs/fusion/test/algorithm/segmented_for_each.cpp
new file mode 100644
index 000000000..d1f4fe6ad
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/segmented_for_each.cpp
@@ -0,0 +1,140 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2011 Eric Niebler
+ Copyright (c) 2018 Kohei Takahashi
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/core/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include "../sequence/tree.hpp"
+
+struct print
+{
+ template <typename T>
+ void operator()(T const& v) const
+ {
+ std::cout << "[ " << v << " ] ";
+ }
+};
+
+struct increment
+{
+ template <typename T>
+ void operator()(T& v) const
+ {
+ ++v;
+ }
+};
+
+struct mutable_increment : increment
+{
+ template <typename T>
+ void operator()(T& v)
+ {
+ return increment::operator()(v);
+ }
+};
+
+template <typename F, typename Tree>
+void test(Tree tree, Tree const& expected)
+{
+ boost::fusion::for_each(tree, F());
+ BOOST_TEST_EQ(tree, expected);
+}
+
+int
+main()
+{
+ using namespace boost::fusion;
+
+ {
+ for_each(
+ make_tree(
+ make_vector(double(0),'B')
+ , make_tree(
+ make_vector(1,2,long(3))
+ , make_tree(make_vector('a','b','c'))
+ , make_tree(make_vector(short('d'),'e','f'))
+ )
+ , make_tree(
+ make_vector(4,5,6)
+ , make_tree(make_vector(float(1),'h','i'))
+ , make_tree(make_vector('j','k','l'))
+ )
+ )
+ , print()
+ );
+ std::cout << std::endl;
+ }
+
+ {
+ test<increment>(
+ make_tree(
+ make_vector(double(0),'B')
+ , make_tree(
+ make_vector(1,2,long(3))
+ , make_tree(make_vector('a','b','c'))
+ , make_tree(make_vector(short('d'),'e','f'))
+ )
+ , make_tree(
+ make_vector(4,5,6)
+ , make_tree(make_vector(float(1),'h','i'))
+ , make_tree(make_vector('j','k','l'))
+ )
+ )
+ , make_tree(
+ make_vector(double(1),'C')
+ , make_tree(
+ make_vector(2,3,long(4))
+ , make_tree(make_vector('b','c','d'))
+ , make_tree(make_vector(short('e'),'f','g'))
+ )
+ , make_tree(
+ make_vector(5,6,7)
+ , make_tree(make_vector(float(2),'i','j'))
+ , make_tree(make_vector('k','l','m'))
+ )
+ )
+ );
+ }
+
+ {
+ test<mutable_increment>(
+ make_tree(
+ make_vector(double(0),'B')
+ , make_tree(
+ make_vector(1,2,long(3))
+ , make_tree(make_vector('a','b','c'))
+ , make_tree(make_vector(short('d'),'e','f'))
+ )
+ , make_tree(
+ make_vector(4,5,6)
+ , make_tree(make_vector(float(1),'h','i'))
+ , make_tree(make_vector('j','k','l'))
+ )
+ )
+ , make_tree(
+ make_vector(double(1),'C')
+ , make_tree(
+ make_vector(2,3,long(4))
+ , make_tree(make_vector('b','c','d'))
+ , make_tree(make_vector(short('e'),'f','g'))
+ )
+ , make_tree(
+ make_vector(5,6,7)
+ , make_tree(make_vector(float(2),'i','j'))
+ , make_tree(make_vector('k','l','m'))
+ )
+ )
+ );
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/ticket-5490.cpp b/src/boost/libs/fusion/test/algorithm/ticket-5490.cpp
new file mode 100644
index 000000000..fedf733a2
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/ticket-5490.cpp
@@ -0,0 +1,41 @@
+/*=============================================================================
+ Copyright (c) 2018 Kohei Takahashi
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/fusion/include/vector.hpp>
+#include <boost/fusion/include/transform.hpp>
+#include <boost/mpl/quote.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/core/ignore_unused.hpp>
+
+using namespace boost::fusion;
+
+template <typename>
+struct predicate {};
+
+struct unique {};
+
+template <typename>
+struct meta_func
+{
+ typedef unique result_type;
+
+ template <typename T>
+ unique operator()(const T&) const;
+};
+
+int main()
+{
+ vector<int> v;
+
+ typedef predicate<boost::mpl::_1> lambda_t;
+ typedef boost::mpl::quote1<predicate> quote_t;
+
+ vector<unique> l = transform(v, meta_func<lambda_t>());
+
+ vector<unique> q = transform(v, meta_func<quote_t>());
+
+ boost::ignore_unused(l, q);
+}
diff --git a/src/boost/libs/fusion/test/algorithm/transform.cpp b/src/boost/libs/fusion/test/algorithm/transform.cpp
new file mode 100644
index 000000000..8609f61cd
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/transform.cpp
@@ -0,0 +1,157 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2007 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/fusion/sequence/io/out.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/algorithm/transformation/transform.hpp>
+#include <boost/type_traits/is_class.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/range_c.hpp>
+#include <boost/type_traits/is_reference.hpp>
+
+struct square
+{
+ template<typename Sig>
+ struct result;
+
+ template <typename T>
+ struct result<square(T)>
+ {
+ typedef int type;
+ };
+
+ template <typename T>
+ int operator()(T x) const
+ {
+ return x * x;
+ }
+};
+
+struct add
+{
+ template<typename Sig>
+ struct result;
+
+ template <typename A, typename B>
+ struct result<add(A, B)>
+ {
+ typedef int type;
+ };
+
+ template <typename A, typename B>
+ int operator()(A a, B b) const
+ {
+ return a + b;
+ }
+};
+
+struct unary_lvalue_transform
+{
+ template<typename Sig>
+ struct result;
+
+ template<typename T>
+ struct result<unary_lvalue_transform(T&)>
+ {
+ typedef T* type;
+ };
+
+ template<typename T>
+ T* operator()(T& t) const
+ {
+ return &t;
+ }
+};
+
+int twice(int v)
+{
+ return v*2;
+}
+
+struct binary_lvalue_transform
+{
+ template<typename Sig>
+ struct result;
+
+ template<typename T0, typename T1>
+ struct result<binary_lvalue_transform(T0&,T1&)>
+ {
+ typedef T0* type;
+ };
+
+ template<typename T0, typename T1>
+ T0* operator()(T0& t0, T1&) const
+ {
+ return &t0;
+ }
+};
+
+int
+main()
+{
+ using namespace boost::fusion;
+ using boost::mpl::range_c;
+
+ std::cout << tuple_open('[');
+ std::cout << tuple_close(']');
+ std::cout << tuple_delimiter(", ");
+
+/// Testing the transform
+
+ {
+ typedef range_c<int, 5, 9> sequence_type;
+ sequence_type sequence;
+ std::cout << boost::fusion::transform(sequence, square()) << std::endl;
+ BOOST_TEST((boost::fusion::transform(sequence, square()) == make_vector(25, 36, 49, 64)));
+ }
+
+ {
+ typedef range_c<int, 5, 9> mpl_list1;
+ std::cout << boost::fusion::transform(mpl_list1(), square()) << std::endl;
+ BOOST_TEST((boost::fusion::transform(mpl_list1(), square()) == make_vector(25, 36, 49, 64)));
+ }
+
+ {
+ vector<int, int, int> tup(1, 2, 3);
+ std::cout << boost::fusion::transform(tup, square()) << std::endl;
+ BOOST_TEST((boost::fusion::transform(tup, square()) == make_vector(1, 4, 9)));
+ }
+
+ {
+ vector<int, int, int> tup1(1, 2, 3);
+ vector<int, int, int> tup2(4, 5, 6);
+ std::cout << boost::fusion::transform(tup1, tup2, add()) << std::endl;
+ BOOST_TEST((boost::fusion::transform(tup1, tup2, add()) == make_vector(5, 7, 9)));
+ }
+
+ {
+ // Unary transform that requires lvalues, just check compilation
+ vector<int, int, int> tup1(1, 2, 3);
+ BOOST_TEST(at_c<0>(boost::fusion::transform(tup1, unary_lvalue_transform())) == &at_c<0>(tup1));
+ BOOST_TEST(*begin(boost::fusion::transform(tup1, unary_lvalue_transform())) == &at_c<0>(tup1));
+ }
+
+ {
+ vector<int, int, int> tup1(1, 2, 3);
+ vector<int, int, int> tup2(4, 5, 6);
+ BOOST_TEST(at_c<0>(boost::fusion::transform(tup1, tup2, binary_lvalue_transform())) == &at_c<0>(tup1));
+ BOOST_TEST(*begin(boost::fusion::transform(tup1, tup2, binary_lvalue_transform())) == &at_c<0>(tup1));
+ }
+
+ {
+ vector<int, int, int> tup1(1, 2, 3);
+ BOOST_TEST(boost::fusion::transform(tup1, twice) == make_vector(2,4,6));
+ }
+
+
+ return boost::report_errors();
+}
+
diff --git a/src/boost/libs/fusion/test/algorithm/zip.cpp b/src/boost/libs/fusion/test/algorithm/zip.cpp
new file mode 100644
index 000000000..b6a4f097e
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/zip.cpp
@@ -0,0 +1,30 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2006 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/algorithm/transformation/zip.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/mpl/vector.hpp>
+
+int main()
+{
+ using namespace boost::fusion;
+ {
+ BOOST_TEST(zip(make_vector(1,2), make_vector('a','b')) == make_vector(make_vector(1,'a'), make_vector(2,'b')));
+ BOOST_TEST(
+ zip(
+ make_vector(1,2),
+ make_vector('a','b'),
+ make_vector(-1,-2))
+ == make_vector(
+ make_vector(1,'a',-1),
+ make_vector(2,'b',-2))); // Zip more than 2 sequences
+ }
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/fusion/test/algorithm/zip2.cpp b/src/boost/libs/fusion/test/algorithm/zip2.cpp
new file mode 100644
index 000000000..f35e4d5d8
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/zip2.cpp
@@ -0,0 +1,30 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2006 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/algorithm/transformation/zip.hpp>
+#include <boost/fusion/sequence/comparison/equal_to.hpp>
+#include <boost/fusion/adapted/mpl.hpp>
+#include <boost/mpl/vector.hpp>
+
+int main()
+{
+ using namespace boost::fusion;
+ {
+ const vector2<int,int> shorter(1,2);
+ const vector3<char,char,char> longer('a', 'b', 'c');
+ const vector2<vector2<int,char>, vector2<int,char> > result(vector2<int,char>(1,'a'), vector2<int,char>(2,'b'));
+ BOOST_TEST(zip(shorter, longer) == result);
+ }
+ {
+ const vector3<int,int,int> longer(1,2,3);
+ const vector2<char,char> shorter('a', 'b');
+ const vector2<vector2<int,char>, vector2<int,char> > result(vector2<int,char>(1,'a'), vector2<int,char>(2,'b'));
+ BOOST_TEST(zip(longer, shorter) == result);
+ }
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/fusion/test/algorithm/zip_ignore.cpp b/src/boost/libs/fusion/test/algorithm/zip_ignore.cpp
new file mode 100644
index 000000000..a12b58201
--- /dev/null
+++ b/src/boost/libs/fusion/test/algorithm/zip_ignore.cpp
@@ -0,0 +1,28 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2007 Dan Marsden
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/container/vector.hpp>
+#include <boost/fusion/algorithm/transformation/zip.hpp>
+#include <boost/fusion/support/unused.hpp>
+#include <boost/fusion/iterator.hpp>
+#include <boost/fusion/sequence/intrinsic.hpp>
+
+int main()
+{
+ using namespace boost::fusion;
+ {
+ vector<int, int> iv(1,2);
+ vector<char, char> cv('a', 'b');
+ BOOST_TEST(at_c<0>(at_c<0>(zip(iv, unused, cv))) == 1);
+ BOOST_TEST(at_c<2>(at_c<0>(zip(iv, unused, cv))) == 'a');
+
+ BOOST_TEST(at_c<0>(at_c<1>(zip(iv, unused, cv))) == 2);
+ BOOST_TEST(at_c<2>(at_c<1>(zip(iv, unused, cv))) == 'b');
+ }
+ return boost::report_errors();
+}