creating branch for fusion 2.1

[SVN r40231]
This commit is contained in:
Joel de Guzman
2007-10-20 23:52:36 +00:00
parent 13b01b0bfe
commit c3fec7efe6
448 changed files with 62241 additions and 0 deletions
+131
View File
@@ -0,0 +1,131 @@
/*=============================================================================
Copyright (c) 2001-2007 Joel de Guzman
Copyright (c) 2005-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/adapted/struct/adapt_assoc_struct.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/front.hpp>
#include <boost/fusion/sequence/intrinsic/back.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/container/vector/convert.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
#include <boost/fusion/sequence/comparison/less.hpp>
#include <boost/fusion/sequence/comparison/less_equal.hpp>
#include <boost/fusion/sequence/comparison/greater.hpp>
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/not.hpp>
#include <boost/type_traits/is_same.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct x_member;
struct y_member;
struct z_member;
struct point
{
int x;
int y;
};
}
BOOST_FUSION_ADAPT_ASSOC_STRUCT(
ns::point,
(int, x, ns::x_member)
(int, y, ns::y_member)
)
int
main()
{
using namespace boost::fusion;
using namespace boost;
using namespace std;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
ns::point p = {123, 456};
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
BOOST_TEST(p == make_vector(6, 9));
BOOST_STATIC_ASSERT(result_of::size<ns::point>::value == 2);
BOOST_STATIC_ASSERT(!result_of::empty<ns::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
}
{
fusion::vector<int, float> v1(4, 2);
ns::point v2 = {5, 3};
fusion::vector<long, double> v3(5, 4);
BOOST_TEST(v1 < v2);
BOOST_TEST(v1 <= v2);
BOOST_TEST(v2 > v1);
BOOST_TEST(v2 >= v1);
BOOST_TEST(v2 < v3);
BOOST_TEST(v2 <= v3);
BOOST_TEST(v3 > v2);
BOOST_TEST(v3 >= v2);
}
{
// conversion from ns::point to vector
ns::point p = {5, 3};
fusion::vector<int, short> v(p);
v = p;
}
{
// conversion from ns::point to list
ns::point p = {5, 3};
fusion::list<int, short> l(p);
l = p;
}
{
// assoc stuff
BOOST_MPL_ASSERT((fusion::result_of::has_key<ns::point, ns::x_member>));
BOOST_MPL_ASSERT((fusion::result_of::has_key<ns::point, ns::y_member>));
BOOST_MPL_ASSERT((mpl::not_<fusion::result_of::has_key<ns::point, ns::z_member> >));
BOOST_MPL_ASSERT((is_same<fusion::result_of::value_at_key<ns::point, ns::x_member>::type, int>));
BOOST_MPL_ASSERT((is_same<fusion::result_of::value_at_key<ns::point, ns::y_member>::type, int>));
ns::point p = {5, 3};
BOOST_TEST(at_key<ns::x_member>(p) == 5);
BOOST_TEST(at_key<ns::y_member>(p) == 3);
}
return boost::report_errors();
}
+106
View File
@@ -0,0 +1,106 @@
/*=============================================================================
Copyright (c) 2001-2007 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/adapted/struct/adapt_struct.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/front.hpp>
#include <boost/fusion/sequence/intrinsic/back.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/container/vector/convert.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
#include <boost/fusion/sequence/comparison/less.hpp>
#include <boost/fusion/sequence/comparison/less_equal.hpp>
#include <boost/fusion/sequence/comparison/greater.hpp>
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct point
{
int x;
int y;
};
}
BOOST_FUSION_ADAPT_STRUCT(
ns::point,
(int, x)
(int, y)
)
int
main()
{
using namespace boost::fusion;
using namespace boost;
using namespace std;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
ns::point p = {123, 456};
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
BOOST_TEST(p == make_vector(6, 9));
BOOST_STATIC_ASSERT(result_of::size<ns::point>::value == 2);
BOOST_STATIC_ASSERT(!result_of::empty<ns::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
}
{
fusion::vector<int, float> v1(4, 2);
ns::point v2 = {5, 3};
fusion::vector<long, double> v3(5, 4);
BOOST_TEST(v1 < v2);
BOOST_TEST(v1 <= v2);
BOOST_TEST(v2 > v1);
BOOST_TEST(v2 >= v1);
BOOST_TEST(v2 < v3);
BOOST_TEST(v2 <= v3);
BOOST_TEST(v3 > v2);
BOOST_TEST(v3 >= v2);
}
{
// conversion from ns::point to vector
ns::point p = {5, 3};
fusion::vector<int, short> v(p);
v = p;
}
{
// conversion from ns::point to list
ns::point p = {5, 3};
fusion::list<int, short> l(p);
l = p;
}
return boost::report_errors();
}
+41
View File
@@ -0,0 +1,41 @@
/*=============================================================================
Copyright (c) 2001-2006 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/adapted/array.hpp>
#include <boost/array.hpp>
#include <boost/fusion/sequence/intrinsic.hpp>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/fusion/iterator.hpp>
#include <boost/mpl/assert.hpp>
int main()
{
using namespace boost::fusion;
typedef boost::array<int,3> array_type;
BOOST_MPL_ASSERT((traits::is_sequence<array_type>));
BOOST_MPL_ASSERT_NOT((traits::is_view<array_type>));
array_type arr = {{1,2,3}};
BOOST_TEST(*begin(arr) == 1);
BOOST_TEST(*next(begin(arr)) == 2);
BOOST_TEST(*advance_c<2>(begin(arr)) == 3);
BOOST_TEST(prior(next(begin(arr))) == begin(arr));
BOOST_TEST(*prior(end(arr)) == 3);
BOOST_TEST(at_c<2>(arr) == 3);
BOOST_TEST(size(arr) == 3);
BOOST_TEST(distance(begin(arr), end(arr)) == 3);
return boost::report_errors();
}
+53
View File
@@ -0,0 +1,53 @@
/*=============================================================================
Copyright (c) 2001-2006 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/generation/make_vector.hpp>
#include <boost/fusion/sequence/generation/make_list.hpp>
#include <boost/fusion/container/list/convert.hpp>
#include <boost/fusion/algorithm/transformation/push_back.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/mpl/vector_c.hpp>
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
vector0 empty;
std::cout << as_list(make_vector(1, 1.23, "harru")) << std::endl;
std::cout << as_list(push_back(empty, 999)) << std::endl;
BOOST_TEST(as_list(make_vector(1, 1.23, "harru")) == make_vector(1, 1.23, std::string("harru")));
BOOST_TEST(as_list(push_back(empty, 999)) == push_back(empty, 999));
}
{
std::cout << as_list(mpl::vector_c<int, 1, 2, 3, 4, 5>()) << std::endl;
BOOST_TEST((as_list(mpl::vector_c<int, 1, 2, 3, 4, 5>())
== mpl::vector_c<int, 1, 2, 3, 4, 5>()));
}
{
// test conversion
list<int, std::string> l(make_vector(123, "harru"));
BOOST_TEST(l == make_vector(123, "harru"));
l = (make_vector(235, "hola")); // test assign
BOOST_TEST(l == make_vector(235, "hola"));
}
return boost::report_errors();
}
+61
View File
@@ -0,0 +1,61 @@
/*=============================================================================
Copyright (c) 2001-2006 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/generation/make_vector.hpp>
#include <boost/fusion/sequence/generation/make_list.hpp>
#include <boost/fusion/container/map/convert.hpp>
#include <boost/fusion/container/vector/convert.hpp>
#include <boost/fusion/algorithm/transformation/push_back.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/support/pair.hpp>
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
vector0 empty;
std::cout << as_map(make_list(make_pair<int>('X'), make_pair<double>("Men"))) << std::endl;
std::cout << as_map(push_back(empty, make_pair<int>(999))) << std::endl;
}
{
typedef pair<int, char> p1;
typedef pair<double, std::string> p2;
result_of::as_map<list<p1, p2> >::type map(make_pair<int>('X'), make_pair<double>("Men"));
std::cout << at_key<int>(map) << std::endl;
std::cout << at_key<double>(map) << std::endl;
BOOST_TEST(at_key<int>(map) == 'X');
BOOST_TEST(at_key<double>(map) == "Men");
}
{
// test conversion
typedef map<
pair<int, char>
, pair<double, std::string> >
map_type;
map_type m(make_vector(make_pair<int>('X'), make_pair<double>("Men")));
BOOST_TEST(as_vector(m) == make_vector(make_pair<int>('X'), make_pair<double>("Men")));
m = (make_vector(make_pair<int>('X'), make_pair<double>("Men"))); // test assign
BOOST_TEST(as_vector(m) == make_vector(make_pair<int>('X'), make_pair<double>("Men")));
}
return boost::report_errors();
}
+64
View File
@@ -0,0 +1,64 @@
/*=============================================================================
Copyright (c) 2001-2006 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/generation/make_vector.hpp>
#include <boost/fusion/sequence/generation/make_list.hpp>
#include <boost/fusion/container/set/convert.hpp>
#include <boost/fusion/container/list/convert.hpp>
#include <boost/fusion/container/vector/convert.hpp>
#include <boost/fusion/algorithm/transformation/push_back.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/mpl/vector_c.hpp>
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
vector0 empty;
std::cout << as_set(make_list(1, 1.23, "harru")) << std::endl;
std::cout << as_set(push_back(empty, 999)) << std::endl;
BOOST_TEST(as_list(as_set(make_list(1, 1.23, "harru")))
== make_list(1, 1.23, std::string("harru")));
BOOST_TEST(as_list(as_set(push_back(empty, 999)))
== push_back(empty, 999));
}
{
result_of::as_set<list<int, double, std::string> >::type set(1, 1.23, "harru");
std::cout << at_key<int>(set) << std::endl;
BOOST_TEST(at_key<int>(set) == 1);
}
{
std::cout << as_set(mpl::vector_c<int, 1, 2, 3, 4, 5>()) << std::endl;
BOOST_TEST((as_list(as_set(mpl::vector_c<int, 1, 2, 3, 4, 5>()))
== mpl::vector_c<int, 1, 2, 3, 4, 5>()));
}
{
// test conversion
set<int, std::string> s(make_vector(123, "harru"));
BOOST_TEST(as_vector(s) == make_vector(123, "harru"));
s = (make_vector(235, "hola")); // test assign
BOOST_TEST(as_vector(s) == make_vector(235, "hola"));
}
return boost::report_errors();
}
+54
View File
@@ -0,0 +1,54 @@
/*=============================================================================
Copyright (c) 2001-2006 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/generation/make_vector.hpp>
#include <boost/fusion/sequence/generation/make_list.hpp>
#include <boost/fusion/container/vector/convert.hpp>
#include <boost/fusion/algorithm/transformation/push_back.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/mpl/vector_c.hpp>
#include <string>
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
vector0 empty;
std::cout << as_vector(make_list(1, 1.23, "harru")) << std::endl;
std::cout << as_vector(push_back(empty, 999)) << std::endl;
BOOST_TEST(as_vector(make_list(1, 1.23, "harru")) == make_list(1, 1.23, std::string("harru")));
BOOST_TEST(as_vector(push_back(empty, 999)) == push_back(empty, 999));
}
{
std::cout << as_vector(mpl::vector_c<int, 1, 2, 3, 4, 5>()) << std::endl;
BOOST_TEST((as_vector(mpl::vector_c<int, 1, 2, 3, 4, 5>())
== mpl::vector_c<int, 1, 2, 3, 4, 5>()));
}
{
// test conversion
vector<int, std::string> v(make_list(123, "harru"));
BOOST_TEST(v == make_list(123, "harru"));
v = (make_list(235, "hola")); // test assign
BOOST_TEST(v == make_list(235, "hola"));
}
return boost::report_errors();
}
+75
View File
@@ -0,0 +1,75 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/container/deque/deque.hpp>
#include <boost/fusion/container/deque/back_extended_deque.hpp>
#include <boost/fusion/sequence/comparison.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/fusion/sequence/intrinsic.hpp>
#include <boost/fusion/iterator.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
int main()
{
using namespace boost::fusion;
{
typedef deque<int, char> initial_deque_type;
initial_deque_type initial_deque(1, 'a');
typedef back_extended_deque<initial_deque_type, long> extended_type;
extended_type extended(initial_deque, 101L);
BOOST_TEST(size(extended) == 3);
BOOST_TEST(extended == make_vector(1, 'a', 101L));
BOOST_TEST(*begin(extended) == 1);
BOOST_TEST(*next(begin(extended)) == 'a');
BOOST_TEST(*prior(end(extended)) == 101L);
BOOST_TEST(distance(begin(extended), end(extended)) == 3);
BOOST_TEST(*advance_c<2>(begin(extended)) == 101L);
}
{
namespace mpl = boost::mpl;
typedef deque<int, char> initial_deque_type;
typedef back_extended_deque<initial_deque_type, long> extended_type;
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 0>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 1>::type, char>));
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 2>::type, long>));
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<mpl::begin<extended_type>::type>::type, int>));
BOOST_MPL_ASSERT((mpl::equal_to<mpl::size<extended_type>::type, mpl::int_<3> >));
}
{
char ch('a');
long l(101L);
int i(1);
typedef deque<int&, char&> initial_deque_type;
initial_deque_type initial_deque(i, ch);
typedef back_extended_deque<initial_deque_type, long&> extended_type;
extended_type extended(initial_deque, l);
BOOST_TEST(extended == make_vector(1, 'a', 101L));
char ch2('b');
long l2(202L);
int i2(2);
extended_type extended2(initial_deque_type(i2, ch2), l2);
extended = extended2;
BOOST_TEST(extended == make_vector(2, 'b', 202L));
BOOST_TEST(i == i2);
BOOST_TEST(ch == ch2);
BOOST_TEST(l == l2);
}
return boost::report_errors();
}
+90
View File
@@ -0,0 +1,90 @@
/*=============================================================================
Copyright (c) 2001-2006 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/adapted/boost_tuple.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/front.hpp>
#include <boost/fusion/sequence/intrinsic/back.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/container/vector/convert.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
#include <boost/fusion/sequence/comparison/less.hpp>
#include <boost/fusion/sequence/comparison/less_equal.hpp>
#include <boost/fusion/sequence/comparison/greater.hpp>
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
#include <string>
int
main()
{
using namespace boost::fusion;
using namespace boost;
using namespace std;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
typedef boost::tuple<int, std::string> tuple_type;
BOOST_MPL_ASSERT_NOT((traits::is_view<tuple_type>));
tuple_type t(123, "Hola!!!");
std::cout << at_c<0>(t) << std::endl;
std::cout << at_c<1>(t) << std::endl;
std::cout << t << std::endl;
BOOST_TEST(t == make_vector(123, "Hola!!!"));
at_c<0>(t) = 6;
at_c<1>(t) = "mama mia";
BOOST_TEST(t == make_vector(6, "mama mia"));
BOOST_STATIC_ASSERT(result_of::size<tuple_type>::value == 2);
BOOST_STATIC_ASSERT(!result_of::empty<tuple_type>::value);
BOOST_TEST(front(t) == 6);
}
{
fusion::vector<int, float> v1(4, 3.3f);
boost::tuple<short, float> v2(5, 3.3f);
fusion::vector<long, double> v3(5, 4.4);
BOOST_TEST(v1 < v2);
BOOST_TEST(v1 <= v2);
BOOST_TEST(v2 > v1);
BOOST_TEST(v2 >= v1);
BOOST_TEST(v2 < v3);
BOOST_TEST(v2 <= v3);
BOOST_TEST(v3 > v2);
BOOST_TEST(v3 >= v2);
}
{
// conversion from boost tuple to vector
fusion::vector<int, std::string> v(tuples::make_tuple(123, "Hola!!!"));
v = tuples::make_tuple(123, "Hola!!!");
}
{
// conversion from boost tuple to list
fusion::list<int, std::string> l(tuples::make_tuple(123, "Hola!!!"));
l = tuples::make_tuple(123, "Hola!!!");
}
return boost::report_errors();
}
+57
View File
@@ -0,0 +1,57 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/sequence/comparison.hpp>
void
equality_test()
{
using namespace boost::fusion;
FUSION_SEQUENCE<int, char> v1(5, 'a');
FUSION_SEQUENCE<int, char> v2(5, 'a');
BOOST_TEST(v1 == v2);
FUSION_SEQUENCE<int, char> v3(5, 'b');
FUSION_SEQUENCE<int, char> t4(2, 'a');
BOOST_TEST(v1 != v3);
BOOST_TEST(v1 != t4);
BOOST_TEST(!(v1 != v2));
FUSION_SEQUENCE<int, char, bool> v5(5, 'a', true);
BOOST_TEST(v1 != v5);
BOOST_TEST(!(v1 == v5));
BOOST_TEST(v5 != v1);
BOOST_TEST(!(v5 == v1));
}
void
ordering_test()
{
using namespace boost::fusion;
FUSION_SEQUENCE<int, float> v1(4, 3.3f);
FUSION_SEQUENCE<short, float> v2(5, 3.3f);
FUSION_SEQUENCE<long, double> v3(5, 4.4);
BOOST_TEST(v1 < v2);
BOOST_TEST(v1 <= v2);
BOOST_TEST(v2 > v1);
BOOST_TEST(v2 >= v1);
BOOST_TEST(v2 < v3);
BOOST_TEST(v2 <= v3);
BOOST_TEST(v3 > v2);
BOOST_TEST(v3 >= v2);
#if defined(FUSION_TEST_FAIL)
FUSION_SEQUENCE<int, char, bool> v5(5, 'a', true);
v1 >= v5;
#endif
}
+87
View File
@@ -0,0 +1,87 @@
/*=============================================================================
Copyright (c) 2005 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 <string>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/list/cons.hpp>
#include <boost/fusion/sequence/generation/make_cons.hpp>
#include <boost/fusion/sequence/generation/cons_tie.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/algorithm/transformation/filter_if.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/lambda.hpp>
int
main()
{
using namespace boost::fusion;
using boost::is_same;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
/// Testing cons
{
std::string hello("hello");
cons<int, cons<std::string> > ns =
make_cons(1, make_cons(hello));
BOOST_TEST((*begin(ns) == 1));
BOOST_TEST((*next(begin(ns)) == hello));
*begin(ns) += 1;
*next(begin(ns)) += ' ';
BOOST_TEST((*begin(ns) == 2));
BOOST_TEST((*next(begin(ns)) == hello + ' '));
for_each(ns, boost::lambda::_1 += ' ');
BOOST_TEST((*begin(ns) == 2 + ' '));
BOOST_TEST((*next(begin(ns)) == hello + ' ' + ' '));
}
{
BOOST_TEST(
make_cons("hello") == make_vector(std::string("hello"))
);
BOOST_TEST(
make_cons(123, make_cons("hello")) ==
make_vector(123, std::string("hello"))
);
}
{
vector<int, float> t(1, 1.1f);
cons<int, cons<float> > nf =
make_cons(1, make_cons(1.1f));
BOOST_TEST((t == nf));
BOOST_TEST((vector<int>(1) == filter_if<is_same<boost::mpl::_, int> >(nf)));
std::cout << nf << std::endl;
std::cout << filter_if<is_same<boost::mpl::_, int> >(nf) << std::endl;
}
{
int i = 3;
cons<int&> tie(cons_tie(i));
BOOST_TEST((*begin(tie) == 3));
}
return boost::report_errors();
}
+117
View File
@@ -0,0 +1,117 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/sequence/intrinsic/at.hpp>
#include <boost/fusion/container/list/cons.hpp>
#if !defined(FUSION_AT)
#define FUSION_AT at_c
#endif
namespace test_detail
{
// something to prevent warnings for unused variables
template<class T> void dummy(const T&) {}
// no public default constructor
class foo
{
public:
explicit foo(int v) : val(v) {}
bool operator==(const foo& other) const
{
return val == other.val;
}
private:
foo() {}
int val;
};
// another class without a public default constructor
class no_def_constructor
{
no_def_constructor() {}
public:
no_def_constructor(std::string) {}
};
}
inline void
test()
{
using namespace boost::fusion;
using namespace test_detail;
nil empty;
FUSION_SEQUENCE<> empty0;
FUSION_SEQUENCE<> empty1(empty);
FUSION_SEQUENCE<int> t1;
BOOST_TEST(FUSION_AT<0>(t1) == int());
FUSION_SEQUENCE<float> t2(5.5f);
BOOST_TEST(FUSION_AT<0>(t2) > 5.4f && FUSION_AT<0>(t2) < 5.6f);
FUSION_SEQUENCE<foo> t3(foo(12));
BOOST_TEST(FUSION_AT<0>(t3) == foo(12));
FUSION_SEQUENCE<double> t4(t2);
BOOST_TEST(FUSION_AT<0>(t4) > 5.4 && FUSION_AT<0>(t4) < 5.6);
FUSION_SEQUENCE<int, float> t5;
BOOST_TEST(FUSION_AT<0>(t5) == int());
BOOST_TEST(FUSION_AT<1>(t5) == float());
FUSION_SEQUENCE<int, float> t6(12, 5.5f);
BOOST_TEST(FUSION_AT<0>(t6) == 12);
BOOST_TEST(FUSION_AT<1>(t6) > 5.4f && FUSION_AT<1>(t6) < 5.6f);
FUSION_SEQUENCE<int, float> t7(t6);
BOOST_TEST(FUSION_AT<0>(t7) == 12);
BOOST_TEST(FUSION_AT<1>(t7) > 5.4f && FUSION_AT<1>(t7) < 5.6f);
FUSION_SEQUENCE<long, double> t8(t6);
BOOST_TEST(FUSION_AT<0>(t8) == 12);
BOOST_TEST(FUSION_AT<1>(t8) > 5.4f && FUSION_AT<1>(t8) < 5.6f);
dummy
(
FUSION_SEQUENCE<no_def_constructor, no_def_constructor, no_def_constructor>(
std::string("Jaba"), // ok, since the default
std::string("Daba"), // constructor is not used
std::string("Doo")
)
);
dummy(FUSION_SEQUENCE<int, double>());
dummy(FUSION_SEQUENCE<int, double>(1,3.14));
#if defined(FUSION_TEST_FAIL)
dummy(FUSION_SEQUENCE<double&>()); // should fail, no defaults for references
dummy(FUSION_SEQUENCE<const double&>()); // likewise
#endif
{
double dd = 5;
dummy(FUSION_SEQUENCE<double&>(dd)); // ok
dummy(FUSION_SEQUENCE<const double&>(dd+3.14)); // ok, but dangerous
}
#if defined(FUSION_TEST_FAIL)
dummy(FUSION_SEQUENCE<double&>(dd+3.14)); // should fail,
// temporary to non-const reference
#endif
}
+98
View File
@@ -0,0 +1,98 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/sequence/intrinsic/at.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/mpl/insert_range.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/begin.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/static_assert.hpp>
#if !defined(FUSION_AT)
#define FUSION_AT at_c
#endif
#if !defined(FUSION_MAKE)
#define FUSION_MAKE BOOST_PP_CAT(make_, FUSION_SEQUENCE)
#endif
#if !defined(FUSION_TIE)
#define FUSION_TIE BOOST_PP_CAT(FUSION_SEQUENCE, _tie)
#endif
namespace test_detail
{
// classes with different kinds of conversions
class AA {};
class BB : public AA {};
struct CC { CC() {} CC(const BB&) {} };
struct DD { operator CC() const { return CC(); }; };
}
boost::fusion::FUSION_SEQUENCE<double, double, double, double>
foo(int i)
{
return boost::fusion::FUSION_MAKE(i, i+1, i+2, i+3);
}
void test_mpl()
{
using namespace boost::fusion;
typedef FUSION_SEQUENCE<int, char> seq;
typedef
boost::mpl::insert_range<
boost::mpl::vector<>
, boost::mpl::end< boost::mpl::vector<> >::type
, seq
>::type
sequence;
typedef boost::mpl::equal<sequence, boost::mpl::vector<int, char> > equal;
BOOST_STATIC_ASSERT(equal::value);
}
void
test()
{
using namespace boost::fusion;
using namespace test_detail;
FUSION_SEQUENCE<int, char> t1(4, 'a');
FUSION_SEQUENCE<int, char> t2(5, 'b');
t2 = t1;
BOOST_TEST(FUSION_AT<0>(t1) == FUSION_AT<0>(t2));
BOOST_TEST(FUSION_AT<1>(t1) == FUSION_AT<1>(t2));
FUSION_SEQUENCE<long, std::string> t3(2, "a");
t3 = t1;
BOOST_TEST((double)FUSION_AT<0>(t1) == FUSION_AT<0>(t3));
BOOST_TEST(FUSION_AT<1>(t1) == FUSION_AT<1>(t3)[0]);
// testing copy and assignment with implicit conversions
// between elements testing tie
FUSION_SEQUENCE<char, BB*, BB, DD> t;
FUSION_SEQUENCE<int, AA*, CC, CC> a(t);
a = t;
int i; char c; double d;
FUSION_TIE(i, c, d) = FUSION_MAKE(1, 'a', 5.5);
BOOST_TEST(i==1);
BOOST_TEST(c=='a');
BOOST_TEST(d>5.4 && d<5.6);
// returning a tuple with conversion
foo(2);
test_mpl();
}
+80
View File
@@ -0,0 +1,80 @@
/*=============================================================================
Copyright (c) 2007 Tobias Schwinger
Use modification and distribution are subject to 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/support/deduce_sequence.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/ref.hpp>
using boost::is_same;
using boost::reference_wrapper;
using boost::fusion::traits::deduce;
using boost::fusion::traits::deduce_sequence;
namespace fusion = boost::fusion;
template <class Args>
struct test_seq_ctor
{
typename deduce_sequence<Args>::type fsq_args;
test_seq_ctor(Args const & args)
: fsq_args(args)
{ }
};
#define TEST_SAME_TYPE(a,b) BOOST_TEST(( is_same< a, b >::value ))
#define TEST_SAME_ELEMENTS(a,b) BOOST_TEST(( boost::mpl::equal< a, b >::type::value ))
typedef fusion::vector<int, int const, int &, int const &> args1;
typedef fusion::vector<int, int const, int &, int> storable1;
template struct test_seq_ctor<args1>;
typedef fusion::vector< reference_wrapper<int> &, reference_wrapper<int const> &,
reference_wrapper<int> const &, reference_wrapper<int const> const & > args2;
typedef fusion::vector<int &, int const &, int &, int const &> storable2;
template struct test_seq_ctor<args2>;
typedef fusion::vector<int *, int const *, int const * const, int const * &, int const * const &> args3;
typedef fusion::vector<int *, int const *, int const * const, int const * &, int const * > storable3;
template struct test_seq_ctor<args3>;
typedef fusion::vector<int(&)[2], int const(&)[2]> args4;
typedef args4 storable4;
template struct test_seq_ctor<args4>;
int main()
{
TEST_SAME_TYPE(deduce<int &>::type, int &);
TEST_SAME_TYPE(deduce<int volatile &>::type, int volatile &);
TEST_SAME_TYPE(deduce<int>::type, int);
TEST_SAME_TYPE(deduce<int const &>::type, int);
TEST_SAME_TYPE(deduce<int const volatile &>::type, int);
TEST_SAME_TYPE(deduce< reference_wrapper<int> & >::type, int &);
TEST_SAME_TYPE(deduce< reference_wrapper<int const> & >::type, int const &);
TEST_SAME_TYPE(deduce< reference_wrapper<int> const & >::type, int &);
TEST_SAME_TYPE(deduce< reference_wrapper<int const> const & >::type, int const &);
TEST_SAME_TYPE(deduce< int(&)[2] >::type, int(&)[2]);
TEST_SAME_TYPE(deduce< int const (&)[2] >::type, int const (&)[2]);
TEST_SAME_TYPE(deduce< int volatile (&)[2] >::type, int volatile (&)[2]);
TEST_SAME_TYPE(deduce< int const volatile (&)[2] >::type, int const volatile (&)[2]);
TEST_SAME_ELEMENTS(deduce_sequence<args1>::type,storable1);
TEST_SAME_ELEMENTS(deduce_sequence<args2>::type,storable2);
TEST_SAME_ELEMENTS(deduce_sequence<args3>::type,storable3);
TEST_SAME_ELEMENTS(deduce_sequence<args4>::type,storable4);
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/deque/deque.hpp>
#define FUSION_SEQUENCE deque
#include "comparison.hpp"
int
main()
{
equality_test();
ordering_test();
return boost::report_errors();
}
+19
View File
@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/deque/deque.hpp>
#define FUSION_SEQUENCE deque
#include "construction.hpp"
int
main()
{
test();
return boost::report_errors();
}
+22
View File
@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/deque/deque.hpp>
#include <boost/fusion/sequence/generation/make_deque.hpp>
#include <boost/fusion/sequence/generation/deque_tie.hpp>
#define FUSION_SEQUENCE deque
#include "copy.hpp"
int
main()
{
test();
return boost::report_errors();
}
+19
View File
@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 2001-2006 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/fusion/container/deque/deque.hpp>
#define FUSION_SEQUENCE deque
#define FUSION_TRAVERSAL_TAG bidirectional_traversal_tag
#include "./iterator.hpp"
int
main()
{
test();
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/deque/deque.hpp>
#include <boost/fusion/sequence/generation/make_deque.hpp>
#define FUSION_SEQUENCE deque
#include "make.hpp"
int
main()
{
test();
return boost::report_errors();
}
+22
View File
@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/deque/deque.hpp>
#include <boost/fusion/container/deque/convert.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#define FUSION_SEQUENCE deque
#include "misc.hpp"
int
main()
{
test();
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2006
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/container/deque/deque.hpp>
#define FUSION_SEQUENCE deque
#include "mutate.hpp"
int
main()
{
test();
return boost::report_errors();
}
+23
View File
@@ -0,0 +1,23 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/deque/deque.hpp>
#include <boost/fusion/sequence/generation/deque_tie.hpp>
#include <boost/fusion/sequence/generation/ignore.hpp>
#include <boost/fusion/sequence/generation/make_deque.hpp>
#define FUSION_SEQUENCE deque
#include "tie.hpp"
int
main()
{
test();
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/deque/deque.hpp>
#define FUSION_SEQUENCE deque
#include "value_at.hpp"
int
main()
{
test();
return boost::report_errors();
}
+146
View File
@@ -0,0 +1,146 @@
/*=============================================================================
Copyright (c) 2001-2006 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/algorithm/iteration/ext_/for_each_s.hpp>
#include <boost/fusion/algorithm/query/ext_/find_if_s.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/ext_/tree.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/view/iterator_range/iterator_range.hpp>
#include <boost/fusion/view/ext_/segmented_iterator_range.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/begin.hpp>
#include <boost/mpl/next.hpp>
#include <boost/static_assert.hpp>
#include <sstream>
struct ostream_fun
{
ostream_fun(std::ostream &sout)
: sout_(sout)
{}
template<typename T>
void operator ()(T const &t) const
{
sout_ << t << ' ';
}
private:
std::ostream & sout_;
};
template<typename Tree>
void
process_tree(Tree const &tree)
{
using namespace boost;
using namespace fusion;
using mpl::_;
typedef typename result_of::find_if_s<Tree const, is_same<_,short> >::type short_iter;
typedef typename result_of::find_if_s<Tree const, is_same<_,float> >::type float_iter;
typedef iterator_range<short_iter, float_iter> slice_t;
BOOST_STATIC_ASSERT(traits::is_segmented<slice_t>::value);
// find_if_s of a segmented data structure returns generic
// segmented iterators
short_iter si = find_if_s<is_same<_,short> >(tree);
float_iter fi = find_if_s<is_same<_,float> >(tree);
// If you put them in an iterator range, the range
// is automatically a segmented data structure.
slice_t slice(si, fi);
std::stringstream sout;
fusion::for_each_s(slice, ostream_fun(sout));
BOOST_TEST((sout.str() == "100 e f 0 B "));
}
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
char const* s = "Ruby";
typedef vector<int, char, double, char const*> vector_type;
vector_type vec(1, 'x', 3.3, s);
{
typedef vector_iterator<vector_type, 1> i1t;
typedef vector_iterator<vector_type, 3> i3t;
i1t i1(vec);
i3t i3(vec);
typedef iterator_range<i1t, i3t> slice_t;
slice_t slice(i1, i3);
std::cout << slice << std::endl;
BOOST_TEST((slice == make_vector('x', 3.3)));
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
}
{
typedef vector_iterator<vector_type, 0> i1t;
typedef vector_iterator<vector_type, 0> i3t;
i1t i1(vec);
i3t i3(vec);
typedef iterator_range<i1t, i3t> slice_t;
slice_t slice(i1, i3);
std::cout << slice << std::endl;
BOOST_TEST(slice == make_vector());
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 0);
}
}
{
typedef boost::mpl::vector_c<int, 2, 3, 4, 5, 6> mpl_vec;
typedef boost::mpl::begin<mpl_vec>::type it0;
typedef boost::mpl::next<it0>::type it1;
typedef boost::mpl::next<it1>::type it2;
typedef boost::mpl::next<it2>::type it3;
it1 f;
it3 l;
typedef iterator_range<it1, it3> slice_t;
slice_t slice(f, l);
std::cout << slice << std::endl;
BOOST_TEST((slice == make_vector(3, 4)));
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
}
{
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();
}
+118
View File
@@ -0,0 +1,118 @@
/*=============================================================================
Copyright (c) 2001-2006 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/vector/vector_iterator.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/view/filter_view/filter_view.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/arg.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/assert.hpp>
struct X
{
operator char const*() const
{
return "<X-object>";
}
};
struct Y
{
operator char const*() const
{
return "<Y-object>";
}
};
struct reject_all
{
template<typename T>
struct apply : boost::mpl::false_
{};
};
int
main()
{
using namespace boost::fusion;
using boost::mpl::int_;
using boost::mpl::_;
using boost::mpl::not_;
using boost::mpl::less;
using boost::mpl::vector_c;
using boost::is_class;
using boost::is_same;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{ // Testing the static find_if (internal function)
typedef vector<int, char, long, X> vector_type;
vector_type v(1, 'x', 987654, X());
typedef vector_iterator<vector_type, 0> begin;
typedef vector_iterator<vector_type, 4> end;
typedef detail::static_find_if<begin, end, is_same<_, long> > filter;
typedef filter::type type;
BOOST_TEST(*type(v) == 987654);
std::cout << *type(v) << std::endl;
std::cout << *filter::call(begin(v)) << std::endl;
BOOST_TEST(*type(v) == *filter::call(begin(v)));
}
{
typedef vector<Y, char, long, X, bool, double> vector_type;
X x; Y y;
vector_type v(y, '@', 987654, x, true, 6.6);
typedef filter_view<vector_type const, not_<is_class<_> > > filter_view_type;
filter_view_type view(v);
std::cout << view << std::endl;
BOOST_TEST((view == make_vector('@', 987654, true, 6.6)));
BOOST_STATIC_ASSERT(result_of::size<filter_view_type>::value == 4);
}
{
// $$$ JDG $$$ For some obscure reason, EDG based compilers
// (e.g. comeau 4.3.3, intel) have problems with this.
// vc7.1 and g++ are ok. The errors from comeau are useless.
typedef vector_c<int, 5, 1, 2, 3, 6, 0, -1> vector_type;
typedef filter_view<vector_type const, less<_, int_<3> > > filter_view_type;
vector_type v;
filter_view_type view(v);
std::cout << view << std::endl;
BOOST_TEST((view == make_vector(1, 2, 0, -1)));
BOOST_STATIC_ASSERT(result_of::size<filter_view_type>::value == 4);
}
{
// Previous filtering out all values caused problems as begin<seq> was not equal to end<seq>
// Picked up by Andreas Pokorny
typedef vector<int> vec;
typedef filter_view<vec, reject_all> filter_view_type;
BOOST_MPL_ASSERT((result_of::equal_to<result_of::begin<filter_view_type>::type, result_of::end<filter_view_type>::type>));
}
return boost::report_errors();
}
+75
View File
@@ -0,0 +1,75 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/container/deque/deque.hpp>
#include <boost/fusion/container/deque/front_extended_deque.hpp>
#include <boost/fusion/sequence/comparison.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/fusion/sequence/intrinsic.hpp>
#include <boost/fusion/iterator.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
int main()
{
using namespace boost::fusion;
{
typedef deque<char, long> initial_deque_type;
initial_deque_type initial_deque('a', 101L);
typedef front_extended_deque<initial_deque_type, int> extended_type;
extended_type extended(initial_deque, 1);
BOOST_TEST(size(extended) == 3);
BOOST_TEST(extended == make_vector(1, 'a', 101L));
BOOST_TEST(*begin(extended) == 1);
BOOST_TEST(*next(begin(extended)) == 'a');
BOOST_TEST(*prior(end(extended)) == 101L);
BOOST_TEST(distance(begin(extended), end(extended)) == 3);
BOOST_TEST(*advance_c<2>(begin(extended)) == 101L);
}
{
namespace mpl = boost::mpl;
typedef deque<char, long> initial_deque_type;
typedef front_extended_deque<initial_deque_type, int> extended_type;
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 0>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 1>::type, char>));
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 2>::type, long>));
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<mpl::begin<extended_type>::type>::type, int>));
BOOST_MPL_ASSERT((mpl::equal_to<mpl::size<extended_type>::type, mpl::int_<3> >));
}
{
char ch('a');
long l(101L);
int i(1);
typedef deque<char&, long&> initial_deque_type;
initial_deque_type initial_deque(ch, l);
typedef front_extended_deque<initial_deque_type, int&> extended_type;
extended_type extended(initial_deque, i);
BOOST_TEST(extended == make_vector(1, 'a', 101L));
char ch2('b');
long l2(202L);
int i2(2);
extended_type extended2(initial_deque_type(ch2, l2), i2);
extended = extended2;
BOOST_TEST(extended == make_vector(2, 'b', 202L));
BOOST_TEST(i == i2);
BOOST_TEST(ch == ch2);
BOOST_TEST(l == l2);
}
return boost::report_errors();
}
+116
View File
@@ -0,0 +1,116 @@
/*=============================================================================
Copyright (C) 1999-2003 Jaakko Järvi
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/generation/make_vector.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/io/in.hpp>
#include <fstream>
#include <iterator>
#include <algorithm>
#include <string>
#if defined BOOST_NO_STRINGSTREAM
# include <strstream>
#else
# include <sstream>
#endif
using boost::fusion::vector;
using boost::fusion::make_vector;
using boost::fusion::tuple_close;
using boost::fusion::tuple_open;
using boost::fusion::tuple_delimiter;
#if defined BOOST_NO_STRINGSTREAM
using std::ostrstream;
using std::istrstream;
typedef ostrstream useThisOStringStream;
typedef istrstream useThisIStringStream;
#else
using std::ostringstream;
using std::istringstream;
typedef ostringstream useThisOStringStream;
typedef istringstream useThisIStringStream;
#endif
using std::endl;
using std::ofstream;
using std::ifstream;
using std::string;
int
main()
{
using boost::fusion::tuple_close;
using boost::fusion::tuple_open;
using boost::fusion::tuple_delimiter;
useThisOStringStream os1;
// Set format [a, b, c] for os1
os1 << tuple_open('[');
os1 << tuple_close(']');
os1 << tuple_delimiter(',');
os1 << make_vector(1, 2, 3);
BOOST_TEST (os1.str() == std::string("[1,2,3]") );
{
useThisOStringStream os2;
// Set format (a:b:c) for os2;
os2 << tuple_open('(');
os2 << tuple_close(')');
os2 << tuple_delimiter(':');
os2 << make_vector("TUPU", "HUPU", "LUPU", 4.5);
BOOST_TEST (os2.str() == std::string("(TUPU:HUPU:LUPU:4.5)") );
}
// The format is still [a, b, c] for os1
os1 << make_vector(1, 2, 3);
BOOST_TEST (os1.str() == std::string("[1,2,3][1,2,3]") );
std::ofstream tmp("temp.tmp");
tmp << make_vector("One", "Two", 3);
tmp << tuple_delimiter(':');
tmp << make_vector(1000, 2000, 3000) << endl;
tmp.close();
// When reading tuples from a stream, manipulators must be set correctly:
ifstream tmp3("temp.tmp");
vector<string, string, int> j;
tmp3 >> j;
BOOST_TEST (tmp3.good() );
tmp3 >> tuple_delimiter(':');
vector<int, int, int> i;
tmp3 >> i;
BOOST_TEST (tmp3.good() );
tmp3.close();
// reading vector<int, int, int> in format (a b c);
useThisIStringStream is("(100 200 300)");
vector<int, int, int> ti;
BOOST_TEST(bool((is >> ti) != 0));
BOOST_TEST(ti == make_vector(100, 200, 300));
// Note that strings are problematic:
// writing a tuple on a stream and reading it back doesn't work in
// general. If this is wanted, some kind of a parseable string class
// should be used.
return boost::report_errors();
}
+197
View File
@@ -0,0 +1,197 @@
/*=============================================================================
Copyright (c) 2001-2006 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 <string>
#include <boost/static_assert.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/iterator/distance.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/value_of.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/value_at.hpp>
void test()
{
using namespace boost::fusion;
using namespace boost;
{ // Testing deref, next, prior, begin, end
char const* s = "Hello";
typedef FUSION_SEQUENCE<int, char, double, char const*> seq_type;
seq_type v(1, 'x', 3.3, s);
result_of::begin<seq_type>::type i(v);
BOOST_TEST(*i == 1);
BOOST_TEST(*next(i) == 'x');
BOOST_TEST(*next(next(i)) == 3.3);
BOOST_TEST(*next(next(next(i))) == s);
next(next(next(next(i)))); // end
#if !defined(FUSION_NO_PRIOR)
BOOST_TEST(*prior(next(next(next(i)))) == 3.3);
BOOST_TEST(*prior(prior(next(next(next(i))))) == 'x');
BOOST_TEST(*prior(prior(prior(next(next(next(i)))))) == 1);
#endif
BOOST_TEST(*begin(v) == 1);
#if !defined(FUSION_NO_PRIOR)
BOOST_TEST(*prior(end(v)) == s);
#endif
*i = 3;
BOOST_TEST(*i == 3);
BOOST_TEST(&*i == &at_c<0>(v));
// prove that it is mutable
*i = 987;
BOOST_TEST(*i == 987);
}
{ // Testing const sequence and const iterator
char const* s = "Hello";
typedef FUSION_SEQUENCE<int, char, double, char const*> const seq_type;
seq_type t(1, 'x', 3.3, s);
result_of::begin<seq_type>::type i(t);
BOOST_TEST(*i == 1);
BOOST_TEST(*next(i) == 'x');
BOOST_TEST(*begin(t) == 1);
#if !defined(FUSION_NO_PRIOR)
BOOST_TEST(*prior(end(t)) == s);
#endif
#ifdef FUSION_TEST_FAIL
*i = 3; // must not compile
#endif
}
{ // Testing iterator equality
typedef FUSION_SEQUENCE<int, char, double, char const*> seq_type;
typedef FUSION_SEQUENCE<int, char, double, char const*> const cseq_type;
typedef result_of::begin<seq_type>::type vi1;
typedef result_of::begin<cseq_type>::type vi2;
BOOST_STATIC_ASSERT((result_of::equal_to<vi1 const, vi1>::value));
BOOST_STATIC_ASSERT((result_of::equal_to<vi1, vi1 const>::value));
BOOST_STATIC_ASSERT((result_of::equal_to<vi1, vi2>::value));
BOOST_STATIC_ASSERT((result_of::equal_to<vi1 const, vi2>::value));
BOOST_STATIC_ASSERT((result_of::equal_to<vi1, vi2 const>::value));
BOOST_STATIC_ASSERT((result_of::equal_to<vi1 const, vi2 const>::value));
}
{
typedef FUSION_SEQUENCE<int, int> seq_type;
typedef result_of::begin<seq_type>::type begin_type;
typedef result_of::end<seq_type>::type end_type;
typedef result_of::next<begin_type>::type i1;
typedef result_of::next<i1>::type i2;
BOOST_STATIC_ASSERT((is_same<end_type, i2>::value));
}
{ // testing deref, next, prior, begin, end
char const* s = "Hello";
typedef FUSION_SEQUENCE<int, char, double, char const*> seq_type;
seq_type t(1, 'x', 3.3, s);
result_of::begin<seq_type>::type i(t);
BOOST_TEST(*i == 1);
BOOST_TEST(*next(i) == 'x');
BOOST_TEST(*next(next(i)) == 3.3);
BOOST_TEST(*next(next(next(i))) == s);
next(next(next(next(i)))); // end
#ifdef FUSION_TEST_FAIL
next(next(next(next(next(i))))); // past the end: must not compile
#endif
#if !defined(FUSION_NO_PRIOR)
BOOST_TEST(*prior(next(next(next(i)))) == 3.3);
BOOST_TEST(*prior(prior(next(next(next(i))))) == 'x');
BOOST_TEST(*prior(prior(prior(next(next(next(i)))))) == 1);
#endif
BOOST_TEST(*begin(t) == 1);
#if !defined(FUSION_NO_PRIOR)
BOOST_TEST(*prior(end(t)) == s);
#endif
*i = 3;
BOOST_TEST(*i == 3);
BOOST_TEST(*i == at_c<0>(t));
}
{ // Testing distance
typedef FUSION_SEQUENCE<int, char, double, char const*> seq_type;
seq_type t(1, 'x', 3.3, "Hello");
BOOST_STATIC_ASSERT((result_of::distance<
result_of::begin<seq_type>::type
, result_of::end<seq_type>::type >::value == 4));
BOOST_TEST(distance(begin(t), end(t)).value == 4);
}
{ // Testing tuple iterator result_of::value_of, result_of::deref, result_of::value_at
typedef FUSION_SEQUENCE<int, char&> seq_type;
typedef result_of::begin<seq_type>::type i0;
typedef result_of::next<i0>::type i1;
typedef result_of::next<result_of::begin<const seq_type>::type>::type i2;
BOOST_STATIC_ASSERT((
is_same<result_of::value_at_c<seq_type, 0>::type, int>::value));
BOOST_STATIC_ASSERT((
is_same<result_of::value_at_c<seq_type, 1>::type, char&>::value));
BOOST_STATIC_ASSERT((
is_same<traits::category_of<i0>::type, FUSION_TRAVERSAL_TAG>::value));
BOOST_STATIC_ASSERT((is_same<result_of::deref<i0>::type, int&>::value));
BOOST_STATIC_ASSERT((is_same<result_of::deref<i1>::type, char&>::value));
BOOST_STATIC_ASSERT((is_same<result_of::value_of<i0>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of::value_of<i1>::type, char&>::value));
}
{ // Testing advance
typedef FUSION_SEQUENCE<int, char, double, char const*> seq_type;
seq_type t(1, 'x', 3.3, "Hello");
BOOST_TEST(*advance_c<0>(begin(t)) == at_c<0>(t));
BOOST_TEST(*advance_c<1>(begin(t)) == at_c<1>(t));
BOOST_TEST(*advance_c<2>(begin(t)) == at_c<2>(t));
BOOST_TEST(*advance_c<3>(begin(t)) == at_c<3>(t));
#if !defined(FUSION_NO_PRIOR)
BOOST_TEST(*advance_c<-1>(end(t)) == at_c<3>(t));
BOOST_TEST(*advance_c<-2>(end(t)) == at_c<2>(t));
BOOST_TEST(*advance_c<-3>(end(t)) == at_c<1>(t));
BOOST_TEST(*advance_c<-4>(end(t)) == at_c<0>(t));
#endif
BOOST_TEST(&*advance_c<0>(begin(t)) == &at_c<0>(t));
BOOST_TEST(&*advance_c<1>(begin(t)) == &at_c<1>(t));
BOOST_TEST(&*advance_c<2>(begin(t)) == &at_c<2>(t));
BOOST_TEST(&*advance_c<3>(begin(t)) == &at_c<3>(t));
}
}
+81
View File
@@ -0,0 +1,81 @@
/*=============================================================================
Copyright (c) 2001-2006 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/generation/make_vector.hpp>
#include <boost/fusion/view/iterator_range/iterator_range.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/begin.hpp>
#include <boost/mpl/next.hpp>
#include <boost/static_assert.hpp>
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
char const* s = "Ruby";
typedef vector<int, char, double, char const*> vector_type;
vector_type vec(1, 'x', 3.3, s);
{
typedef vector_iterator<vector_type, 1> i1t;
typedef vector_iterator<vector_type, 3> i3t;
i1t i1(vec);
i3t i3(vec);
typedef iterator_range<i1t, i3t> slice_t;
slice_t slice(i1, i3);
std::cout << slice << std::endl;
BOOST_TEST((slice == make_vector('x', 3.3)));
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
}
{
typedef vector_iterator<vector_type, 0> i1t;
typedef vector_iterator<vector_type, 0> i3t;
i1t i1(vec);
i3t i3(vec);
typedef iterator_range<i1t, i3t> slice_t;
slice_t slice(i1, i3);
std::cout << slice << std::endl;
BOOST_TEST(slice == make_vector());
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 0);
}
}
{
typedef boost::mpl::vector_c<int, 2, 3, 4, 5, 6> mpl_vec;
typedef boost::mpl::begin<mpl_vec>::type it0;
typedef boost::mpl::next<it0>::type it1;
typedef boost::mpl::next<it1>::type it2;
typedef boost::mpl::next<it2>::type it3;
it1 f;
it3 l;
typedef iterator_range<it1, it3> slice_t;
slice_t slice(f, l);
std::cout << slice << std::endl;
BOOST_TEST((slice == make_vector(3, 4)));
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
}
return boost::report_errors();
}
+144
View File
@@ -0,0 +1,144 @@
/*=============================================================================
Copyright (c) 2001-2006 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/view/joint_view/joint_view.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/mpl/vector_c.hpp>
struct X
{
operator char const*() const
{
return "<X-object>";
}
};
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
/// Testing joint_view
{
vector<int> t1(3);
vector<X> t2;
typedef joint_view<vector<int>, vector<X> > view_type;
view_type view(t1, t2);
std::cout << view << std::endl;
BOOST_TEST((view == make_vector(3, X())));
}
{
vector<int, char> t1(3, 'x');
vector<X> t2;
typedef joint_view<vector<int, char>, vector<X> > view_type;
view_type view(t1, t2);
std::cout << view << std::endl;
BOOST_TEST((view == make_vector(3, 'x', X())));
*begin(view) = 4;
BOOST_TEST(at_c<0>(t1) == 4);
}
{
vector<int, char> t1(3, 'x');
vector<X, int> t2;
typedef joint_view<vector<int, char>, vector<X, int> > view_type;
view_type view(t1, t2);
std::cout << view << std::endl;
BOOST_TEST((view == make_vector(3, 'x', X(), 0)));
}
{
typedef vector<int> t1_type;
t1_type t1(777);
typedef vector<int, char, double> t2_type;
t2_type t2(1, 'x', 3.3);
{
typedef joint_view<t1_type, t2_type> view_type;
view_type view(t1, t2);
std::cout << view << std::endl;
BOOST_TEST((view == make_vector(777, 1, 'x', 3.3)));
}
{
typedef joint_view<t2_type, t1_type> view_type;
view_type view(t2, t1);
std::cout << view << std::endl;
BOOST_TEST((view == make_vector(1, 'x', 3.3, 777)));
}
{
typedef joint_view<t2_type, t1_type> jv_type;
typedef joint_view<jv_type, jv_type> jv2_type;
jv_type jv(t2, t1);
jv2_type jv2(jv, jv);
std::cout << jv << std::endl;
std::cout << jv2 << std::endl;
BOOST_TEST(jv2
== make_vector(1, 'x', 3.3, 777, 1, 'x', 3.3, 777));
}
{
typedef joint_view<t2_type, t1_type> jt_type;
typedef joint_view<t1_type, t2_type> jv2_type;
typedef joint_view<jt_type, jv2_type> jv3_type;
jt_type jt(t2, t1);
jv2_type jv2(t1, t2);
jv3_type jv3(jt, jv2);
std::cout << jt << std::endl;
std::cout << jv2 << std::endl;
std::cout << jv3 << std::endl;
BOOST_TEST(jv3
== make_vector(1, 'x', 3.3, 777, 777, 1, 'x', 3.3));
}
{
typedef joint_view<vector<>, t1_type> jt_type;
vector<> empty;
jt_type jt(empty, t1);
std::cout << jt << std::endl;
BOOST_TEST(jt == make_vector(777));
}
{
typedef joint_view<t1_type, vector<> > jt_type;
vector<> empty;
jt_type jt(t1, empty);
std::cout << jt << std::endl;
BOOST_TEST(jt == make_vector(777));
}
{
typedef joint_view<vector<>, vector<> > jt_type;
vector<> empty;
jt_type jt(empty, empty);
std::cout << jt << std::endl;
BOOST_TEST(jt == make_vector());
}
}
return boost::report_errors();
}
+19
View File
@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/list/list.hpp>
#define FUSION_SEQUENCE list
#include "comparison.hpp"
int
main()
{
equality_test();
ordering_test();
return boost::report_errors();
}
+18
View File
@@ -0,0 +1,18 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/list/list.hpp>
#define FUSION_SEQUENCE list
#include "construction.hpp"
int
main()
{
test();
return boost::report_errors();
}
+21
View File
@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/list/list.hpp>
#include <boost/fusion/sequence/generation/make_list.hpp>
#include <boost/fusion/sequence/generation/list_tie.hpp>
#define FUSION_SEQUENCE list
#include "copy.hpp"
int
main()
{
test();
return boost::report_errors();
}
+22
View File
@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 2001-2006 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/fusion/container/list/list.hpp>
#define FUSION_SEQUENCE list
#define FUSION_NO_PRIOR
#define FUSION_TRAVERSAL_TAG forward_traversal_tag
#include "./iterator.hpp"
int
main()
{
test();
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/list/list.hpp>
#include <boost/fusion/sequence/generation/make_list.hpp>
#define FUSION_SEQUENCE list
#include "make.hpp"
int
main()
{
test();
return boost::report_errors();
}
+21
View File
@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/list/list.hpp>
#include <boost/fusion/container/list/convert.hpp>
#define FUSION_SEQUENCE list
#define FUSION_FORWARD_ONLY
#include "misc.hpp"
int
main()
{
test();
return boost::report_errors();
}
+19
View File
@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/list/list.hpp>
#define FUSION_SEQUENCE list
#include "mutate.hpp"
int
main()
{
test();
return boost::report_errors();
}
+22
View File
@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/list/list.hpp>
#include <boost/fusion/sequence/generation/list_tie.hpp>
#include <boost/fusion/sequence/generation/ignore.hpp>
#include <boost/fusion/sequence/generation/make_list.hpp>
#define FUSION_SEQUENCE list
#include "tie.hpp"
int
main()
{
test();
return boost::report_errors();
}
+19
View File
@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/list/list.hpp>
#define FUSION_SEQUENCE list
#include "value_at.hpp"
int
main()
{
test();
return boost::report_errors();
}
+88
View File
@@ -0,0 +1,88 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <string>
#if !defined(FUSION_AT)
#define FUSION_AT at_c
#endif
#if !defined(FUSION_MAKE)
#define FUSION_MAKE BOOST_PP_CAT(make_, FUSION_SEQUENCE)
#endif
namespace test_detail
{
// something to prevent warnings for unused variables
template<class T> void dummy(const T&) {}
class A {};
class B {};
}
void make_tuple_test() {}
void
test()
{
using namespace boost::fusion;
using namespace test_detail;
{
FUSION_SEQUENCE<int, char> t1 = FUSION_MAKE(5, 'a');
BOOST_TEST(FUSION_AT<0>(t1) == 5);
BOOST_TEST(FUSION_AT<1>(t1) == 'a');
FUSION_SEQUENCE<int, std::string> t2;
t2 = FUSION_MAKE((short int)2, std::string("Hi"));
BOOST_TEST(FUSION_AT<0>(t2) == 2);
BOOST_TEST(FUSION_AT<1>(t2) == "Hi");
}
{ // This test was previously disallowed for non-PTS compilers.
A a = A(); B b;
const A ca = a;
FUSION_MAKE(boost::cref(a), b);
FUSION_MAKE(boost::ref(a), b);
FUSION_MAKE(boost::ref(a), boost::cref(b));
FUSION_MAKE(boost::ref(ca));
}
{ // the result of make_xxx is assignable:
BOOST_TEST(FUSION_MAKE(2, 4, 6) ==
(FUSION_MAKE(1, 2, 3) = FUSION_MAKE(2, 4, 6)));
}
{ // This test was previously disallowed for non-PTS compilers.
FUSION_MAKE("Donald", "Daisy"); // should work;
// std::make_pair("Doesn't","Work"); // fails
}
{
// You can store a reference to a function in a sequence
FUSION_SEQUENCE<void(&)()> adf(make_tuple_test);
dummy(adf); // avoid warning for unused variable
}
#if defined(FUSION_TEST_FAIL)
{
// But make_xxx doesn't work
// with function references, since it creates a const
// qualified function type
FUSION_MAKE(make_tuple_test);
}
#endif
{
// With function pointers, make_xxx works just fine
FUSION_MAKE(&make_tuple_test);
}
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/list/list.hpp>
#include <boost/fusion/sequence/generation/make_list.hpp>
#define FUSION_SEQUENCE list
#include "make.hpp"
int
main()
{
test();
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/vector/vector.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#define FUSION_SEQUENCE vector
#include "make.hpp"
int
main()
{
test();
return boost::report_errors();
}
+72
View File
@@ -0,0 +1,72 @@
/*=============================================================================
Copyright (c) 2001-2006 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/map/map.hpp>
#include <boost/fusion/sequence/generation/make_map.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/support/pair.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/static_assert.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
#include <string>
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(", ");
{
typedef map<
pair<int, char>
, pair<double, std::string> >
map_type;
BOOST_MPL_ASSERT((traits::is_associative<map_type>));
map_type m(
make_pair<int>('X')
, make_pair<double>("Men"));
std::cout << at_key<int>(m) << std::endl;
std::cout << at_key<double>(m) << std::endl;
BOOST_TEST(at_key<int>(m) == 'X');
BOOST_TEST(at_key<double>(m) == "Men");
BOOST_STATIC_ASSERT((
boost::is_same<result_of::value_at_key<map_type, int>::type, char>::value));
BOOST_STATIC_ASSERT((
boost::is_same<result_of::value_at_key<map_type, double>::type, std::string>::value));
std::cout << m << std::endl;
BOOST_STATIC_ASSERT((result_of::has_key<map_type, int>::value));
BOOST_STATIC_ASSERT((result_of::has_key<map_type, double>::value));
BOOST_STATIC_ASSERT((!result_of::has_key<map_type, std::string>::value));
}
{
std::cout << make_map<char, int>('X', 123) << std::endl;
BOOST_TEST(at_key<char>(make_map<char, int>('X', 123)) == 'X');
BOOST_TEST(at_key<int>(make_map<char, int>('X', 123)) == 123);
}
return boost::report_errors();
}
+35
View File
@@ -0,0 +1,35 @@
/*=============================================================================
Copyright (c) 2001-2006 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/sequence/generation/map_tie.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
struct key_zero;
struct key_one;
int main()
{
using namespace boost::fusion;
{
int number = 101;
char letter = 'a';
BOOST_TEST(at_key<key_zero>(map_tie<key_zero, key_one>(number, letter)) == 101);
BOOST_TEST(at_key<key_one>(map_tie<key_zero, key_one>(number, letter)) == 'a');
BOOST_TEST(&at_key<key_zero>(map_tie<key_zero, key_one>(number, letter)) == &number);
BOOST_TEST(&at_key<key_one>(map_tie<key_zero, key_one>(number, letter)) == &letter);
at_key<key_zero>(map_tie<key_zero, key_one>(number, letter)) = 202;
at_key<key_one>(map_tie<key_zero, key_one>(number, letter)) = 'b';
BOOST_TEST(number == 202);
BOOST_TEST(letter == 'b');
}
return boost::report_errors();
}
+189
View File
@@ -0,0 +1,189 @@
/*=============================================================================
Copyright (C) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/sequence/intrinsic.hpp>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/type_traits/is_same.hpp>
#include <string>
#if !defined(FUSION_AT)
#define FUSION_AT at_c
#endif
#if !defined(FUSION_SIZE)
#define FUSION_SIZE result_of::size
#endif
template <typename S1, typename S2>
struct is_same
{
};
struct test_intrinsics1
{
// test at, begin, end, next, prior, advance, size, deref, etc.
typedef boost::fusion::FUSION_SEQUENCE<int, float, bool, char> sequence;
typedef boost::mpl::begin<sequence>::type first;
typedef boost::mpl::next<first>::type second;
typedef boost::mpl::next<second>::type third;
typedef boost::mpl::next<third>::type fourth;
typedef boost::mpl::end<sequence>::type last;
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::deref<first>::type, int>::value));
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::deref<second>::type, float>::value));
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::deref<third>::type, bool>::value));
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::deref<fourth>::type, char>::value));
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::at_c<sequence, 2>::type, bool>::value));
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::front<sequence>::type, int>::value));
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::deref<
boost::mpl::advance_c<second, 2>::type>::type, char>::value));
BOOST_STATIC_ASSERT((boost::mpl::size<sequence>::value == 4));
BOOST_STATIC_ASSERT(!(boost::mpl::empty<sequence>::value));
BOOST_STATIC_ASSERT((boost::mpl::distance<second, fourth>::value == 2));
#if !defined(FUSION_FORWARD_ONLY) // list has no back/prev
typedef boost::mpl::prior<last>::type fourth_;
typedef boost::mpl::prior<fourth_>::type third_;
typedef boost::mpl::prior<third_>::type second_;
typedef boost::mpl::prior<second_>::type first_;
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::deref<first_>::type, int>::value));
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::deref<second_>::type, float>::value));
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::deref<third_>::type, bool>::value));
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::deref<fourth_>::type, char>::value));
BOOST_STATIC_ASSERT((boost::is_same<
boost::mpl::back<sequence>::type, char>::value));
#endif
};
struct test_intrinsics2
{
typedef boost::fusion::FUSION_SEQUENCE<> seq0;
#if !defined(FUSION_FORWARD_ONLY) // list has no back/prev
typedef boost::fusion::FUSION_SEQUENCE<int> target1;
typedef boost::mpl::push_back<seq0, int>::type seq1;
BOOST_STATIC_ASSERT((boost::mpl::equal<seq1, target1>::value));
typedef boost::fusion::FUSION_SEQUENCE<int, double> target2;
typedef boost::mpl::push_back<seq1, double>::type seq2;
BOOST_STATIC_ASSERT((boost::mpl::equal<seq2, target2>::value));
#endif
typedef boost::fusion::FUSION_SEQUENCE<int> target3;
typedef boost::mpl::push_front<seq0, int>::type seq3;
BOOST_STATIC_ASSERT((boost::mpl::equal<seq3, target3>::value));
typedef boost::fusion::FUSION_SEQUENCE<double, int> target4;
typedef boost::mpl::push_front<seq3, double>::type seq4;
BOOST_STATIC_ASSERT((boost::mpl::equal<seq4, target4>::value));
};
void
test()
{
using namespace boost::fusion;
{ // testing const sequences
const FUSION_SEQUENCE<int, float> t1(5, 3.3f);
BOOST_TEST(FUSION_AT<0>(t1) == 5);
BOOST_TEST(FUSION_AT<1>(t1) == 3.3f);
}
{ // testing at<N> works with MPL integral constants
const FUSION_SEQUENCE<int, char> t1(101, 'z');
BOOST_TEST(boost::fusion::at<boost::mpl::int_<0> >(t1) == 101);
BOOST_TEST(boost::fusion::at<boost::mpl::int_<1> >(t1) == 'z');
// explicitly try something other than mpl::int_
BOOST_TEST((boost::fusion::at<boost::mpl::integral_c<long, 0> >(t1) == 101));
BOOST_TEST((boost::fusion::at<boost::mpl::integral_c<long, 1> >(t1) == 'z'));
}
{ // testing size & empty
typedef FUSION_SEQUENCE<int, float, double> t1;
typedef FUSION_SEQUENCE<> t2;
BOOST_STATIC_ASSERT(FUSION_SIZE<t1>::value == 3);
BOOST_STATIC_ASSERT(FUSION_SIZE<t2>::value == 0);
BOOST_STATIC_ASSERT(!result_of::empty<t1>::value);
BOOST_STATIC_ASSERT(result_of::empty<t2>::value);
}
{ // testing front & back
typedef FUSION_SEQUENCE<int, float, std::string> tup;
tup t(1, 2.2, "Kimpo");
BOOST_TEST(front(t) == 1);
#if !defined(FUSION_FORWARD_ONLY) // list has no back
BOOST_TEST(back(t) == "Kimpo");
#endif
}
{ // testing is_sequence
typedef FUSION_SEQUENCE<int, float, double> t1;
typedef FUSION_SEQUENCE<> t2;
typedef FUSION_SEQUENCE<char> t3;
BOOST_STATIC_ASSERT(traits::is_sequence<t1>::value);
BOOST_STATIC_ASSERT(traits::is_sequence<t2>::value);
BOOST_STATIC_ASSERT(traits::is_sequence<t3>::value);
BOOST_STATIC_ASSERT(!traits::is_sequence<int>::value);
BOOST_STATIC_ASSERT(!traits::is_sequence<char>::value);
}
{ // testing mpl compatibility
// test begin, end, next, prior, advance, size, deref, etc.
//~ typedef FUSION_SEQUENCE<int, float, bool, char> tuple_type;
//~ test_intrinsics1<tuple_type> test1;
//~ (void)test1; // prevent unused variable warning
// test an algorithm
typedef FUSION_SEQUENCE<int, float, double> t1;
typedef boost::mpl::find<t1, float>::type iter;
typedef boost::mpl::deref<iter>::type type;
BOOST_STATIC_ASSERT((boost::is_same<type, float>::value));
}
}
+52
View File
@@ -0,0 +1,52 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/sequence/intrinsic/at.hpp>
#if !defined(FUSION_AT)
#define FUSION_AT at_c
#endif
namespace test_detail
{
// no public default constructor
class foo
{
public:
explicit foo(int v) : val(v) {}
bool operator==(const foo& other) const
{
return val == other.val;
}
private:
foo() {}
int val;
};
}
void
test()
{
using namespace boost::fusion;
using namespace test_detail;
FUSION_SEQUENCE<int, float, bool, foo> t1(5, 12.2f, true, foo(4));
FUSION_AT<0>(t1) = 6;
FUSION_AT<1>(t1) = 2.2f;
FUSION_AT<2>(t1) = false;
FUSION_AT<3>(t1) = foo(5);
BOOST_TEST(FUSION_AT<0>(t1) == 6);
BOOST_TEST(FUSION_AT<1>(t1) > 2.1f && FUSION_AT<1>(t1) < 2.3f);
BOOST_TEST(FUSION_AT<2>(t1) == false);
BOOST_TEST(FUSION_AT<3>(t1) == foo(5));
}
+53
View File
@@ -0,0 +1,53 @@
/*=============================================================================
Copyright (c) 2007 Tobias Schwinger
Use modification and distribution are subject to 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/view/repetitive_view.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/view/joint_view.hpp>
#include <boost/fusion/algorithm/transformation/zip.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/functional/generation/make_fused_procedure.hpp>
struct check_equal
{
template<typename LHS, typename RHS>
void operator()(LHS const& lhs, RHS const& rhs) const
{
BOOST_TEST(( boost::is_same<LHS,RHS>::value ));
BOOST_TEST(( lhs == rhs ));
}
};
int main()
{
using namespace boost::fusion;
typedef boost::fusion::vector<int,long,float,double> seq_t;
seq_t seq(1,2l,3.0f,4.0);
typedef repetitive_view<seq_t> view_t;
view_t view(seq);
typedef joint_view<seq_t,seq_t> seq_twice_t;
typedef joint_view<seq_t,seq_twice_t> seq_repeated_t;
seq_twice_t seq_twice(seq,seq);
seq_repeated_t seq_repeated(seq,seq_twice);
for_each(zip(view,seq_repeated), make_fused_procedure(check_equal()));
return boost::report_errors();
}
+64
View File
@@ -0,0 +1,64 @@
/*=============================================================================
Copyright (c) 2001-2006 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/generation/make_vector.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/view/reverse_view/reverse_view.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/distance.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 l;
reverse_view<mpl_list1> rev(l);
std::cout << rev << std::endl;
BOOST_TEST((rev == make_vector(8, 7, 6, 5)));
}
{
char const* s = "Hi Kim";
typedef vector<int, char, long, char const*> vector_type;
vector_type t(123, 'x', 123456789, s);
typedef reverse_view<vector_type> view_type;
view_type rev(t);
std::cout << rev << std::endl;
BOOST_TEST((rev == make_vector(s, 123456789, 'x', 123)));
typedef result_of::begin<view_type>::type first_type;
first_type first_it(begin(rev));
typedef result_of::next<first_type>::type second_type;
second_type second_it(next(first_it));
BOOST_TEST((*second_it == 123456789));
BOOST_TEST((*prior(second_it) == s));
BOOST_TEST((*advance_c<2>(first_it) == 'x'));
BOOST_TEST((distance(first_it, second_it) == 1));
}
return boost::report_errors();
}
+67
View File
@@ -0,0 +1,67 @@
/*=============================================================================
Copyright (c) 2001-2006 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/sequence/generation/make_set.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/support/pair.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/static_assert.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
#include <string>
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(", ");
{
typedef set<int, std::string> set_type;
BOOST_MPL_ASSERT((traits::is_associative<set_type>));
set_type m(123, "Hola");
std::cout << at_key<int>(m) << std::endl;
std::cout << at_key<std::string>(m) << std::endl;
BOOST_TEST(at_key<int>(m) == 123);
BOOST_TEST(at_key<std::string>(m) == "Hola");
BOOST_STATIC_ASSERT((
boost::is_same<result_of::value_at_key<set_type, int>::type, int>::value));
BOOST_STATIC_ASSERT((
boost::is_same<result_of::value_at_key<set_type, std::string>::type, std::string>::value));
std::cout << m << std::endl;
BOOST_STATIC_ASSERT((result_of::has_key<set_type, int>::value));
BOOST_STATIC_ASSERT((result_of::has_key<set_type, std::string>::value));
BOOST_STATIC_ASSERT((!result_of::has_key<set_type, double>::value));
}
{
std::cout << make_set('X', 123) << std::endl;
BOOST_TEST(at_key<char>(make_set('X', 123)) == 'X');
BOOST_TEST(at_key<int>(make_set('X', 123)) == 123);
}
return boost::report_errors();
}
+57
View File
@@ -0,0 +1,57 @@
/*=============================================================================
Copyright (c) 2001-2006 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/sequence/io/out.hpp>
#include <boost/fusion/view/single_view/single_view.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/iterator/deref.hpp>
struct X {};
template <typename OS>
OS& operator<<(OS& os, X const&)
{
os << "<X-object>";
return os;
}
void foo() {}
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
single_view<int> view1(3);
std::cout << view1 << std::endl;
#ifdef FUSION_TEST_FAIL
// single_view is immutable
*begin(view1) += 4;
#endif
std::cout << view1 << std::endl;
BOOST_TEST(*begin(view1) == 3);
BOOST_TEST(view1.val == 3);
single_view<X> view2;
std::cout << view2 << std::endl;
}
{
std::cout << make_single_view(1) << std::endl;
std::cout << make_single_view("Hello, World") << std::endl;
std::cout << make_single_view(&foo) << std::endl;
}
return boost::report_errors();
}
+91
View File
@@ -0,0 +1,91 @@
/*=============================================================================
Copyright (c) 2001-2006 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/adapted/std_pair.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/front.hpp>
#include <boost/fusion/sequence/intrinsic/back.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/container/vector/convert.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
#include <boost/fusion/sequence/comparison/less.hpp>
#include <boost/fusion/sequence/comparison/less_equal.hpp>
#include <boost/fusion/sequence/comparison/greater.hpp>
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
#include <string>
#include <utility>
int
main()
{
using namespace boost::fusion;
using namespace boost;
using namespace std;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
typedef std::pair<int, std::string> pair_type;
BOOST_MPL_ASSERT_NOT((traits::is_view<pair_type>));
pair_type p(123, "Hola!!!");
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, "Hola!!!"));
at_c<0>(p) = 6;
at_c<1>(p) = "mama mia";
BOOST_TEST(p == make_vector(6, "mama mia"));
BOOST_STATIC_ASSERT(result_of::size<pair_type>::value == 2);
BOOST_STATIC_ASSERT(!result_of::empty<pair_type>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == "mama mia");
}
{
fusion::vector<int, float> v1(4, 3.3f);
std::pair<short, float> v2(5, 3.3f);
fusion::vector<long, double> v3(5, 4.4);
BOOST_TEST(v1 < v2);
BOOST_TEST(v1 <= v2);
BOOST_TEST(v2 > v1);
BOOST_TEST(v2 >= v1);
BOOST_TEST(v2 < v3);
BOOST_TEST(v2 <= v3);
BOOST_TEST(v3 > v2);
BOOST_TEST(v3 >= v2);
}
{
// conversion from pair to vector
fusion::vector<int, std::string> v(std::make_pair(123, "Hola!!!"));
v = std::make_pair(123, "Hola!!!");
}
{
// conversion from pair to list
fusion::list<int, std::string> l(std::make_pair(123, "Hola!!!"));
l = std::make_pair(123, "Hola!!!");
}
return boost::report_errors();
}
+35
View File
@@ -0,0 +1,35 @@
/*=============================================================================
Copyright (c) 2001-2006 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/fusion/sequence/intrinsic/swap.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <vector>
int main()
{
namespace fusion = boost::fusion;
{
typedef fusion::vector<std::vector<int>, char> test_vector;
BOOST_MPL_ASSERT((boost::is_same<void, fusion::result_of::swap<test_vector, test_vector>::type>));
test_vector v1(std::vector<int>(1, 101), 'a'), v2(std::vector<int>(1, 202), 'b');
fusion::swap(v1, v2);
BOOST_TEST(v1 == fusion::make_vector(std::vector<int>(1, 202), 'b'));
BOOST_TEST(v2 == fusion::make_vector(std::vector<int>(1, 101), 'a'));
}
return boost::report_errors();
}
+85
View File
@@ -0,0 +1,85 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/sequence/intrinsic/at.hpp>
#if !defined(FUSION_AT)
#define FUSION_AT at_c
#endif
#if !defined(FUSION_MAKE)
#define FUSION_MAKE BOOST_PP_CAT(make_, FUSION_SEQUENCE)
#endif
#if !defined(FUSION_TIE)
#define FUSION_TIE BOOST_PP_CAT(FUSION_SEQUENCE, _tie)
#endif
namespace test_detail
{
// something to prevent warnings for unused variables
template<class T> void dummy(const T&) {}
// no public default constructor
class foo
{
public:
explicit foo(int v) : val(v) {}
bool operator==(const foo& other) const
{
return val == other.val;
}
private:
foo() {}
int val;
};
}
void
test()
{
using namespace boost::fusion;
using namespace test_detail;
int a;
char b;
foo c(5);
FUSION_TIE(a, b, c) = FUSION_MAKE(2, 'a', foo(3));
BOOST_TEST(a == 2);
BOOST_TEST(b == 'a');
BOOST_TEST(c == foo(3));
FUSION_TIE(a, ignore, c) = FUSION_MAKE((short int)5, false, foo(5));
BOOST_TEST(a == 5);
BOOST_TEST(b == 'a');
BOOST_TEST(c == foo(5));
int i, j;
FUSION_TIE(i, j) = FUSION_MAKE(1, 2);
BOOST_TEST(i == 1 && j == 2);
FUSION_SEQUENCE<int, int, float> ta;
#if defined(FUSION_TEST_FAIL)
ta = std::FUSION_MAKE(1, 2); // should fail, tuple is of length 3, not 2
#endif
dummy(ta);
// ties cannot be rebound
int d = 3;
FUSION_SEQUENCE<int&> ti(a);
BOOST_TEST(&FUSION_AT<0>(ti) == &a);
ti = FUSION_SEQUENCE<int&>(d);
BOOST_TEST(&FUSION_AT<0>(ti) == &a);
}
+115
View File
@@ -0,0 +1,115 @@
/*=============================================================================
Copyright (c) 2001-2006 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/generation/make_vector.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/view/transform_view/transform_view.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/distance.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
struct square
{
template<typename T>
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 T>
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;
}
};
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
/// Testing the transform_view
{
typedef boost::mpl::range_c<int, 5, 9> sequence_type;
sequence_type sequence;
square sq;
typedef transform_view<sequence_type, square> xform_type;
xform_type xform(sequence, sq);
std::cout << xform << std::endl;
BOOST_TEST((xform == make_vector(25, 36, 49, 64)));
typedef boost::fusion::result_of::begin<xform_type>::type first_type;
first_type first_it(boost::fusion::begin(xform));
typedef boost::fusion::result_of::next<first_type>::type next_type;
next_type next_it(boost::fusion::next(first_it));
BOOST_TEST((*next_it == 36));
BOOST_TEST((*boost::fusion::prior(next_it) == 25));
BOOST_TEST((boost::fusion::distance(first_it, next_it) == 1));
BOOST_TEST((*boost::fusion::advance_c<3>(boost::fusion::begin(xform)) == 64));
BOOST_TEST((boost::fusion::at_c<2>(xform) == 49));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_c<xform_type, 0>::type, int>));
}
{
typedef boost::mpl::range_c<int, 5, 9> sequence1_type;
typedef boost::mpl::range_c<int, 10, 14> sequence2_type;
sequence1_type sequence1;
sequence2_type sequence2;
add f;
typedef transform_view<sequence1_type, sequence2_type, add> xform_type;
xform_type xform(sequence1, sequence2, f);
std::cout << xform << std::endl;
BOOST_TEST((xform == make_vector(15, 17, 19, 21)));
BOOST_TEST((boost::fusion::at_c<2>(xform) == 19));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_c<xform_type, 0>::type, int>));
}
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/tuple/tuple.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#define FUSION_SEQUENCE tuple
#include "comparison.hpp"
int
main()
{
equality_test();
ordering_test();
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/tuple/tuple.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#define FUSION_SEQUENCE tuple
#define FUSION_AT get
#include "construction.hpp"
int
main()
{
test();
return boost::report_errors();
}
+22
View File
@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/tuple.hpp>
#define FUSION_SEQUENCE tuple
#define FUSION_AT get
#define FUSION_MAKE make_tuple
#define FUSION_TIE tie
#include "copy.hpp"
int
main()
{
test();
return boost::report_errors();
}
+21
View File
@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/tuple.hpp>
#define FUSION_SEQUENCE tuple
#define FUSION_AT get
#define FUSION_VALUE_AT(S, N) tuple_element<N, S>
#include "value_at.hpp"
int
main()
{
test();
return boost::report_errors();
}
+21
View File
@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/tuple.hpp>
#define FUSION_SEQUENCE tuple
#define FUSION_AT get
#define FUSION_MAKE make_tuple
#include "make.hpp"
int
main()
{
test();
return boost::report_errors();
}
+23
View File
@@ -0,0 +1,23 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/tuple.hpp>
#include <boost/fusion/container/vector/convert.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#define FUSION_SEQUENCE tuple
#define FUSION_AT get
#define FUSION_SIZE tuple_size
#include "misc.hpp"
int
main()
{
test();
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/tuple.hpp>
#define FUSION_SEQUENCE tuple
#define FUSION_AT get
#include "mutate.hpp"
int
main()
{
test();
return boost::report_errors();
}
+22
View File
@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/tuple.hpp>
#define FUSION_SEQUENCE tuple
#define FUSION_AT get
#define FUSION_MAKE make_tuple
#define FUSION_TIE tie
#include "tie.hpp"
int
main()
{
test();
return boost::report_errors();
}
+87
View File
@@ -0,0 +1,87 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#if !defined(FUSION_AT)
#define FUSION_AT at_c
#endif
#if !defined(FUSION_VALUE_AT)
#define FUSION_VALUE_AT(S, N) result_of::value_at_c<S, N>
#endif
namespace test_detail
{
// something to prevent warnings for unused variables
template<class T> void dummy(const T&) {}
class A {};
}
void
test()
{
using namespace boost::fusion;
using namespace test_detail;
double d = 2.7;
A a;
FUSION_SEQUENCE<int, double&, const A&, int> t(1, d, a, 2);
const FUSION_SEQUENCE<int, double&, const A, int> ct(t);
int i = FUSION_AT<0>(t);
int i2 = FUSION_AT<3>(t);
BOOST_TEST(i == 1 && i2 == 2);
int j = FUSION_AT<0>(ct);
BOOST_TEST(j == 1);
FUSION_AT<0>(t) = 5;
BOOST_TEST(FUSION_AT<0>(t) == 5);
#if defined(FUSION_TEST_FAIL)
FUSION_AT<0>(ct) = 5; // can't assign to const
#endif
double e = FUSION_AT<1>(t);
BOOST_TEST(e > 2.69 && e < 2.71);
FUSION_AT<1>(t) = 3.14+i;
BOOST_TEST(FUSION_AT<1>(t) > 4.13 && FUSION_AT<1>(t) < 4.15);
#if defined(FUSION_TEST_FAIL)
FUSION_AT<4>(t) = A(); // can't assign to const
dummy(FUSION_AT<5>(ct)); // illegal index
#endif
++FUSION_AT<0>(t);
BOOST_TEST(FUSION_AT<0>(t) == 6);
typedef FUSION_SEQUENCE<int, float> seq_type;
BOOST_STATIC_ASSERT(!(
boost::is_const<FUSION_VALUE_AT(seq_type, 0)::type>::value));
// constness should not affect
BOOST_STATIC_ASSERT(!(
boost::is_const<FUSION_VALUE_AT(const seq_type, 0)::type>::value));
BOOST_STATIC_ASSERT(!(
boost::is_const<FUSION_VALUE_AT(seq_type, 1)::type>::value));
// constness should not affect
BOOST_STATIC_ASSERT(!(
boost::is_const<FUSION_VALUE_AT(const seq_type, 1)::type>::value));
dummy(i); dummy(i2); dummy(j); dummy(e); // avoid warns for unused variables
}
+56
View File
@@ -0,0 +1,56 @@
/*=============================================================================
Copyright (c) 2001-2006 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/fusion/adapted/variant.hpp>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/distance.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/variant.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <string>
int main()
{
namespace fusion = boost::fusion;
typedef boost::variant<double, std::string> var_type;
var_type var = "hello";
BOOST_MPL_ASSERT((fusion::traits::is_sequence<var_type>));
BOOST_MPL_ASSERT_NOT((fusion::traits::is_view<var_type>));
BOOST_MPL_ASSERT((boost::is_same<
fusion::traits::category_of<var_type>::type,
fusion::forward_traversal_tag>));
BOOST_TEST(fusion::size(var) == 2);
BOOST_TEST(fusion::distance(fusion::begin(var), fusion::end(var)) == 2);
BOOST_TEST(*fusion::next(fusion::begin(var)) == "hello");
BOOST_TEST(fusion::next(fusion::next(fusion::begin(var))) == fusion::end(var));
BOOST_MPL_ASSERT((boost::is_same<
fusion::result_of::value_of<fusion::result_of::begin<var_type>::type>::type,
double>));
BOOST_MPL_ASSERT((boost::is_same<
fusion::result_of::value_of<fusion::result_of::next<fusion::result_of::begin<var_type>::type>::type>::type,
std::string>));
return boost::report_errors();
}
+19
View File
@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/vector/vector.hpp>
#define FUSION_SEQUENCE vector
#include "comparison.hpp"
int
main()
{
equality_test();
ordering_test();
return boost::report_errors();
}
+18
View File
@@ -0,0 +1,18 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/vector/vector.hpp>
#define FUSION_SEQUENCE vector
#include "construction.hpp"
int
main()
{
test();
return boost::report_errors();
}
+21
View File
@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/vector/vector.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/sequence/generation/vector_tie.hpp>
#define FUSION_SEQUENCE vector
#include "copy.hpp"
int
main()
{
test();
return boost::report_errors();
}
+22
View File
@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 2001-2006 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/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/vector/vector_iterator.hpp>
#define FUSION_SEQUENCE vector
#define FUSION_TRAVERSAL_TAG random_access_traversal_tag
#include "./iterator.hpp"
int
main()
{
test();
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/vector/vector.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#define FUSION_SEQUENCE vector
#include "make.hpp"
int
main()
{
test();
return boost::report_errors();
}
+21
View File
@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/vector/convert.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#define FUSION_SEQUENCE vector
#include "misc.hpp"
int
main()
{
test();
return boost::report_errors();
}
+19
View File
@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/vector/vector.hpp>
#define FUSION_SEQUENCE vector
#include "mutate.hpp"
int
main()
{
test();
return boost::report_errors();
}
+232
View File
@@ -0,0 +1,232 @@
/*=============================================================================
Copyright (c) 2001-2006 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/vector10.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/fusion/container/vector/vector20.hpp>
#include <boost/fusion/container/vector/vector30.hpp>
#include <boost/fusion/container/vector/vector40.hpp>
#include <boost/fusion/container/vector/vector50.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_empty.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <boost/fusion/algorithm/transformation/push_back.hpp>
#include <boost/mpl/vector_c.hpp>
int
main()
{
using namespace boost::fusion;
using namespace boost;
using namespace std;
{
vector0 vec;
(void) vec;
cout << "(): " << sizeof(vec) << endl;
cout << (boost::is_empty<vector0>::value ? "is empty" : "is not empty") << endl;
}
{
typedef vector1<int> type;
type vec;
BOOST_STATIC_ASSERT(result_of::size<type>::value == 1);
BOOST_TEST(at_c<0>(vec) == 0);
BOOST_STATIC_ASSERT((is_same<int, result_of::value_at_c<type, 0>::type>::value));
// prove that it is mutable
at_c<0>(vec) = 987;
BOOST_TEST(at_c<0>(vec) == 987);
}
{
typedef vector1<int> type;
type vec(123);
BOOST_TEST(at_c<0>(vec) == 123);
cout << "(int): " << sizeof(vec) << endl;
}
{ // testing const vector
vector1<short> const vec(999);
BOOST_TEST(at_c<0>(vec) == 999);
#ifdef FUSION_TEST_COMPILE_FAIL
at_c<0>(vec) = 321;
#endif
}
{
vector1<int> t1(123L); // try conversion from long to int
vector1<double> t2(t1); // try copy
(void)t2;
}
{
typedef vector2<int, char> type;
type vec;
BOOST_STATIC_ASSERT(result_of::size<type>::value == 2);
BOOST_TEST(at_c<0>(vec) == 0);
BOOST_TEST(at_c<1>(vec) == char());
BOOST_STATIC_ASSERT((is_same<int, result_of::value_at_c<type, 0>::type>::value));
BOOST_STATIC_ASSERT((is_same<char, result_of::value_at_c<type, 1>::type>::value));
}
{
typedef vector2<int, char> type;
type vec(123, 'x');
BOOST_TEST(at_c<0>(vec) == 123);
BOOST_TEST(at_c<1>(vec) == 'x');
cout << "(int, char): " << sizeof(vec) << endl;
}
{
vector2<int, int> t1(123, 456);
vector2<double, float> t2(t1);
(void)t2;
}
{
typedef vector3<int, char, double> type;
type vec;
BOOST_STATIC_ASSERT(result_of::size<type>::value == 3);
BOOST_TEST(at_c<0>(vec) == 0);
BOOST_TEST(at_c<1>(vec) == char());
BOOST_TEST(at_c<2>(vec) == double());
BOOST_STATIC_ASSERT((is_same<int, result_of::value_at_c<type, 0>::type>::value));
BOOST_STATIC_ASSERT((is_same<char, result_of::value_at_c<type, 1>::type>::value));
BOOST_STATIC_ASSERT((is_same<double, result_of::value_at_c<type, 2>::type>::value));
}
{
typedef vector3<int, char, double> type;
type vec(123, 'x', 123.456);
BOOST_TEST(at_c<0>(vec) == 123);
BOOST_TEST(at_c<1>(vec) == 'x');
BOOST_TEST(at_c<2>(vec) >= 123.455 && at_c<2>(vec) <= 123.457);
cout << "(int, char, double): " << sizeof(vec) << endl;
}
{
typedef vector4<int, char, double, bool> type;
type vec(123, 'x', 123.456, true);
cout << "(int, char, double, bool): " << sizeof(vec) << endl;
}
{
typedef vector4<int, char, bool, double> type;
type vec(123, 'x', true, 123.456);
cout << "(int, char, bool, double): " << sizeof(vec) << endl;
}
{
typedef vector7<bool, char, short, int, long, float, double> type;
type vec(false, 'x', 3, 4, 5, 6.0, 7.0);
BOOST_TEST(at_c<0>(vec) == false);
BOOST_TEST(at_c<1>(vec) == 'x');
BOOST_TEST(at_c<2>(vec) == 3);
BOOST_TEST(at_c<3>(vec) == 4);
BOOST_TEST(at_c<4>(vec) == 5);
BOOST_TEST(at_c<5>(vec) >= 5.9 && at_c<5>(vec) <= 6.1);
BOOST_TEST(at_c<6>(vec) >= 6.9 && at_c<6>(vec) <= 7.1);
BOOST_STATIC_ASSERT((is_same<bool, result_of::value_at_c<type, 0>::type>::value));
BOOST_STATIC_ASSERT((is_same<char, result_of::value_at_c<type, 1>::type>::value));
BOOST_STATIC_ASSERT((is_same<short, result_of::value_at_c<type, 2>::type>::value));
BOOST_STATIC_ASSERT((is_same<int, result_of::value_at_c<type, 3>::type>::value));
BOOST_STATIC_ASSERT((is_same<long, result_of::value_at_c<type, 4>::type>::value));
BOOST_STATIC_ASSERT((is_same<float, result_of::value_at_c<type, 5>::type>::value));
BOOST_STATIC_ASSERT((is_same<double, result_of::value_at_c<type, 6>::type>::value));
cout << "(bool, char, short, int, long, float, double): " << sizeof(vec) << endl;
}
{
typedef vector10<int, int, int, int, int, int, int, int, int, int> type;
type vec; // compile check only
cout << "vector10 of int: " << sizeof(vec) << endl;
}
{
typedef vector20<
int, int, int, int, int, int, int, int, int, int
, int, int, int, int, int, int, int, int, int, int> type;
type vec; // compile check only
cout << "vector20 of int: " << sizeof(vec) << endl;
}
{
typedef vector30<
int, int, int, int, int, int, int, int, int, int
, int, int, int, int, int, int, int, int, int, int
, int, int, int, int, int, int, int, int, int, int> type;
type vec; // compile check only
cout << "vector30 of int: " << sizeof(vec) << endl;
}
{
typedef vector40<
int, int, int, int, int, int, int, int, int, int
, int, int, int, int, int, int, int, int, int, int
, int, int, int, int, int, int, int, int, int, int
, int, int, int, int, int, int, int, int, int, int> type;
type vec; // compile check only
cout << "vector40 of int: " << sizeof(vec) << endl;
}
{
typedef vector50<
int, int, int, int, int, int, int, int, int, int
, int, int, int, int, int, int, int, int, int, int
, int, int, int, int, int, int, int, int, int, int
, int, int, int, int, int, int, int, int, int, int
, int, int, int, int, int, int, int, int, int, int> type;
type vec; // compile check only
cout << "vector50 of int: " << sizeof(vec) << endl;
}
{
// testing copy and assign from a view
vector0 empty;
fusion::vector2<int, long> v(fusion::push_back(fusion::push_back(empty, 123), 456));
BOOST_TEST(at_c<0>(v) == 123);
BOOST_TEST(at_c<1>(v) == 456);
v = fusion::push_back(fusion::push_back(empty, 123), 456); // test assign
BOOST_TEST(at_c<0>(v) == 123);
BOOST_TEST(at_c<1>(v) == 456);
}
{
// testing copy and assign from a vector_c
mpl::vector_c<int, 123, 456> vec_c;
fusion::vector2<int, long> v(vec_c);
BOOST_TEST(at_c<0>(v) == 123);
BOOST_TEST(at_c<1>(v) == 456);
v = mpl::vector_c<int, 123, 456>(); // test assign
BOOST_TEST(at_c<0>(v) == 123);
BOOST_TEST(at_c<1>(v) == 456);
}
return boost::report_errors();
}
+22
View File
@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/vector/vector.hpp>
#include <boost/fusion/sequence/generation/vector_tie.hpp>
#include <boost/fusion/sequence/generation/ignore.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#define FUSION_SEQUENCE vector
#include "tie.hpp"
int
main()
{
test();
return boost::report_errors();
}
+19
View File
@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Järvi
Copyright (c) 2001-2006 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/fusion/container/vector/vector.hpp>
#define FUSION_SEQUENCE vector
#include "value_at.hpp"
int
main()
{
test();
return boost::report_errors();
}
+87
View File
@@ -0,0 +1,87 @@
/*=============================================================================
Copyright (c) 2001-2006 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/support/category_of.hpp>
#include <boost/fusion/view/zip_view.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/front.hpp>
#include <boost/fusion/sequence/intrinsic/back.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
int main()
{
using namespace boost::fusion;
{
typedef vector2<int,int> int_vector;
typedef vector2<char,char> char_vector;
typedef vector<int_vector&, char_vector&> seqs_type;
typedef zip_view<seqs_type> view;
BOOST_MPL_ASSERT((boost::mpl::equal_to<boost::fusion::result_of::size<view>::type, boost::fusion::result_of::size<int_vector>::type>));
BOOST_STATIC_ASSERT((boost::fusion::result_of::size<view>::value == 2));
int_vector iv(1,2);
char_vector cv('a', 'b');
seqs_type seqs(iv, cv);
view v(seqs);
BOOST_TEST(at_c<0>(v) == make_vector(1, 'a'));
BOOST_TEST(at_c<1>(v) == make_vector(2, 'b'));
BOOST_TEST(front(v) == make_vector(1, 'a'));
BOOST_TEST(back(v) == make_vector(2, 'b'));
BOOST_TEST(*next(begin(v)) == make_vector(2, 'b'));
BOOST_TEST(*prior(end(v)) == make_vector(2, 'b'));
BOOST_TEST(advance_c<2>(begin(v)) == end(v));
BOOST_TEST(advance_c<-2>(end(v)) == begin(v));
BOOST_TEST(distance(begin(v), end(v)) == 2);
BOOST_STATIC_ASSERT((boost::fusion::result_of::distance<boost::fusion::result_of::begin<view>::type, boost::fusion::result_of::end<view>::type>::value == 2));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_c<view,0>::type, vector<int,char> >));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_of<boost::fusion::result_of::begin<view>::type>::type, vector<int,char> >));
}
{
using namespace boost;
typedef mpl::vector2<int,bool> v1_type;
typedef mpl::vector2<char,long> v2_type;
typedef fusion::vector<v1_type&, v2_type&> seqs_type;
typedef fusion::zip_view<seqs_type> view;
v1_type v1;
v2_type v2;
seqs_type seqs(v1,v2);
view v(seqs);
BOOST_TEST((fusion::at_c<0>(v) == mpl::vector2<int,char>()));
BOOST_TEST((fusion::at_c<1>(v) == mpl::vector2<bool,long>()));
BOOST_TEST((fusion::front(v) == mpl::vector2<int,char>()));
BOOST_TEST((fusion::back(v) == mpl::vector2<bool,long>()));
BOOST_TEST((*fusion::next(fusion::begin(v)) == mpl::vector2<bool,long>()));
BOOST_TEST((*fusion::prior(fusion::end(v)) == mpl::vector2<bool,long>()));
BOOST_TEST(fusion::advance_c<2>(fusion::begin(v)) == fusion::end(v));
BOOST_TEST(fusion::advance_c<-2>(fusion::end(v)) == fusion::begin(v));
BOOST_TEST(fusion::distance(fusion::begin(v), fusion::end(v)) == 2);
}
return boost::report_errors();
}
+64
View File
@@ -0,0 +1,64 @@
/*=============================================================================
Copyright (c) 2001-2006 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/detail/lightweight_test.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/view/zip_view.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/front.hpp>
#include <boost/fusion/sequence/intrinsic/back.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/prior.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/generation/make_vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
int main()
{
{
using namespace boost::fusion;
typedef vector2<int,int> int_vector;
typedef vector2<char,char> char_vector;
typedef list<char,char> char_list;
typedef vector<int_vector&, char_vector&, char_list&> seqs_type;
typedef zip_view<seqs_type> view;
BOOST_MPL_ASSERT((boost::mpl::equal_to<boost::fusion::result_of::size<view>::type, boost::fusion::result_of::size<int_vector>::type>));
BOOST_STATIC_ASSERT((boost::fusion::result_of::size<view>::value == 2));
int_vector iv(1,2);
char_vector cv('a', 'b');
char_list cl('y','z');
seqs_type seqs(iv, cv, cl);
view v(seqs);
BOOST_TEST(at_c<0>(v) == make_vector(1, 'a', 'y'));
BOOST_TEST(at_c<1>(v) == make_vector(2, 'b', 'z'));
BOOST_TEST(front(v) == make_vector(1, 'a', 'y'));
BOOST_TEST(*next(begin(v)) == make_vector(2, 'b', 'z'));
BOOST_TEST(advance_c<2>(begin(v)) == end(v));
BOOST_TEST(distance(begin(v), end(v)) == 2);
BOOST_STATIC_ASSERT((boost::fusion::result_of::distance<boost::fusion::result_of::begin<view>::type, boost::fusion::result_of::end<view>::type>::value == 2));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_c<view,0>::type, vector<int,char,char> >));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_of<boost::fusion::result_of::begin<view>::type>::type, vector<int,char,char> >));
}
return boost::report_errors();
}
+58
View File
@@ -0,0 +1,58 @@
/*=============================================================================
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/view/zip_view.hpp>
#include <boost/fusion/support/unused.hpp>
#include <boost/fusion/iterator.hpp>
#include <boost/fusion/sequence/intrinsic.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
int main()
{
using namespace boost::fusion;
{
typedef vector2<int,int> int_vector;
typedef vector2<char,char> char_vector;
typedef vector<int_vector&, unused_type const&, char_vector&> seqs_type;
typedef zip_view<seqs_type> view;
int_vector iv(1,2);
char_vector cv('a','b');
seqs_type seq(iv, unused, cv);
view v(seq);
BOOST_TEST(at_c<0>(front(v)) == 1);
BOOST_TEST(at_c<2>(front(v)) == 'a');
BOOST_TEST(at_c<0>(back(v)) == 2);
BOOST_TEST(at_c<2>(back(v)) == 'b');
typedef result_of::begin<view>::type first_iterator;
typedef result_of::value_of<first_iterator>::type first_element;
typedef result_of::at_c<first_element, 0>::type e0;
typedef result_of::at_c<first_element, 2>::type e2;
BOOST_MPL_ASSERT((boost::is_same<e0, int&>));
BOOST_MPL_ASSERT((boost::is_same<e2, char&>));
BOOST_TEST(size(front(v)) == 3);
typedef result_of::value_at_c<view, 0>::type first_value_at;
typedef result_of::value_at_c<first_value_at, 0>::type v0;
typedef result_of::value_at_c<first_value_at, 2>::type v2;
BOOST_MPL_ASSERT((boost::is_same<v0, int>));
BOOST_MPL_ASSERT((boost::is_same<v2, char>));
BOOST_TEST(at_c<0>(at_c<0>(v)) == 1);
BOOST_TEST(at_c<2>(at_c<0>(v)) == 'a');
}
return boost::report_errors();
}