early-access version 3088

This commit is contained in:
pineappleEA
2022-11-05 15:35:56 +01:00
parent 4e4fc25ce3
commit b601909c6d
35519 changed files with 5996896 additions and 860 deletions

View File

@@ -0,0 +1,311 @@
/*=============================================================================
Copyright (c) 2001-2009 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/adt/adapt_adt.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/value_at.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/container/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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <iostream>
#include <string>
namespace ns
{
class point
{
public:
point() : x(0), y(0), z(0) {}
point(int in_x, int in_y, int in_z) : x(in_x), y(in_y), z(in_z) {}
int get_x() const { return x; }
int get_y() const { return y; }
int get_z() const { return z; }
void set_x(int x_) { x = x_; }
void set_y(int y_) { y = y_; }
void set_z(int z_) { z = z_; }
private:
int x;
int y;
int z;
};
#if !BOOST_WORKAROUND(__GNUC__,<4)
class point_with_private_members
{
friend struct boost::fusion::extension::access;
public:
point_with_private_members() : x(0), y(0), z(0) {}
point_with_private_members(int in_x, int in_y, int in_z)
: x(in_x), y(in_y), z(in_z) {}
int get_x() const { return x; }
int get_y() const { return y; }
int get_z() const { return z; }
void set_x(int x_) { x = x_; }
void set_y(int y_) { y = y_; }
void set_z(int z_) { z = z_; }
private:
int x;
int y;
int z;
};
#endif
// A sequence that has data members defined in an unrelated namespace
// (std, in this case). This allows testing ADL issues.
class name
{
public:
name() {}
name(const std::string& last, const std::string& first)
: last(last), first(first) {}
const std::string& get_last() const { return last; }
const std::string& get_first() const { return first; }
void set_last(const std::string& last_) { last = last_; }
void set_first(const std::string& first_) { first = first_; }
private:
std::string last;
std::string first;
};
}
#if BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ADT(
ns::point,
(int, int, obj.get_x(), obj.set_x(val))
// Mixing auto & BOOST_FUSION_ADAPT_AUTO to test backward compatibility
(auto, BOOST_FUSION_ADAPT_AUTO, obj.get_y(), obj.set_y(val))
(obj.get_z(), obj.set_z(val))
)
# if !BOOST_WORKAROUND(__GNUC__,<4)
BOOST_FUSION_ADAPT_ADT(
ns::point_with_private_members,
(obj.get_x(), obj.set_x(val))
(obj.get_y(), obj.set_y(val))
(obj.get_z(), obj.set_z(val))
)
# endif
BOOST_FUSION_ADAPT_ADT(
ns::name,
(obj.get_last(), obj.set_last(val))
(obj.get_first(), obj.set_first(val))
)
#else // BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ADT(
ns::point,
(int, int, obj.get_x(), obj.set_x(val))
(auto, auto, obj.get_y(), obj.set_y(val))
(auto, auto, obj.get_z(), obj.set_z(val))
)
# if !BOOST_WORKAROUND(__GNUC__,<4)
BOOST_FUSION_ADAPT_ADT(
ns::point_with_private_members,
(auto, auto, obj.get_x(), obj.set_x(val))
(auto, auto, obj.get_y(), obj.set_y(val))
(auto, auto, obj.get_z(), obj.set_z(val))
)
# endif
BOOST_FUSION_ADAPT_ADT(
ns::name,
(const std::string&, const std::string&, obj.get_last(), obj.set_last(val))
(BOOST_FUSION_ADAPT_AUTO, auto, obj.get_first(), obj.set_first(val))
)
#endif
class empty_adt{};
BOOST_FUSION_ADAPT_ADT(empty_adt,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
BOOST_STATIC_ASSERT(!traits::is_view<ns::point>::value);
ns::point p(123, 456, 789);
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<ns::point>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<ns::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
{
fusion::vector<int, float, int> v1(4, 2.f, 2);
ns::point v2(5, 3, 3);
fusion::vector<long, double, int> 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);
}
{
fusion::vector<std::string, std::string> v1("Lincoln", "Abraham");
ns::name v2("Roosevelt", "Franklin");
ns::name v3("Roosevelt", "Theodore");
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, 3);
fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from ns::point to list
ns::point p(5, 3, 3);
fusion::list<int, long, int> l(p);
l = p;
}
{
BOOST_MPL_ASSERT((mpl::is_sequence<ns::point>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_at_c<ns::point,0>::type
, mpl::front<ns::point>::type>));
}
#if !BOOST_WORKAROUND(__GNUC__,<4)
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point_with_private_members>));
BOOST_STATIC_ASSERT(!traits::is_view<ns::point_with_private_members>::value);
ns::point_with_private_members p(123, 456, 789);
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<ns::point_with_private_members>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<ns::point_with_private_members>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
#endif
{
// Check types provided in case it's provided
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::front<ns::point>::type,
boost::fusion::extension::adt_attribute_proxy<ns::point,0,false>
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::front<ns::point>::type::type,
int
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::front<ns::point const>::type,
boost::fusion::extension::adt_attribute_proxy<ns::point,0,true>
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::front<ns::point const>::type::type,
int
>));
// Check types provided in case it's deduced
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::back<ns::point>::type,
boost::fusion::extension::adt_attribute_proxy<ns::point,2,false>
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::back<ns::point>::type::type,
int
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::back<ns::point const>::type,
boost::fusion::extension::adt_attribute_proxy<ns::point,2,true>
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::back<ns::point const>::type::type,
int
>));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,87 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/adt/adapt_adt.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
class empty_adt{};
BOOST_FUSION_ADAPT_ADT(empty_adt,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_adt>));
BOOST_STATIC_ASSERT(!traits::is_view<empty_adt>::value);
empty_adt e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_adt>::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_adt>));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<empty_adt>::type,
fusion::result_of::end<empty_adt>::type>));
}
{
fusion::vector<> v;
empty_adt e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(v != e);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
empty_adt e;
// conversion from empty_adt to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_adt to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_adt>));
return boost::report_errors();
}

View File

@@ -0,0 +1,161 @@
/*=============================================================================
Copyright (c) 2001-2009 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/adt/adapt_adt_named.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/value_at.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/container/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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
class point
{
public:
point() : x(0), y(0), z(0) {}
point(int in_x, int in_y, int in_z) : x(in_x), y(in_y), z(in_z) {}
int get_x() const { return x; }
int get_y() const { return y; }
int get_z() const { return z; }
void set_x(int x_) { x = x_; }
void set_y(int y_) { y = y_; }
void set_z(int z_) { z = z_; }
private:
int x;
int y;
int z;
};
}
#if BOOST_PP_VARIADICS
// this creates a fusion view: boost::fusion::adapted::point
BOOST_FUSION_ADAPT_ADT_NAMED(
ns::point, point,
(int, int, obj.get_x(), obj.set_x(val))
(int, int, obj.get_y(), obj.set_y(val))
(obj.get_z(), obj.set_z(val))
)
#else // BOOST_PP_VARIADICS
// this creates a fusion view: boost::fusion::adapted::point
BOOST_FUSION_ADAPT_ADT_NAMED(
ns::point, point,
(int, int, obj.get_x(), obj.set_x(val))
(int, int, obj.get_y(), obj.set_y(val))
(auto, auto, obj.get_z(), obj.set_z(val))
)
#endif // BOOST_PP_VARIADICS
class empty_adt{};
BOOST_FUSION_ADAPT_ADT_NAMED(empty_adt,renamed_empty_adt,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT((traits::is_view<adapted::point>));
BOOST_STATIC_ASSERT(traits::is_view<adapted::point>::value);
ns::point basep(123, 456, 789);
adapted::point p(basep);
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<adapted::point>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<adapted::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
{
fusion::vector<int, float, int> v1(4, 2.f, 2);
ns::point basep(5, 3, 3);
adapted::point v2(basep);
fusion::vector<long, double, int> 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 ns::point to vector
ns::point basep(5, 3, 3);
adapted::point p(basep);
fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from ns::point to list
ns::point basep(5, 3, 3);
adapted::point p(basep);
fusion::list<int, long, float> l(p);
l = p;
}
{
BOOST_MPL_ASSERT((mpl::is_sequence<adapted::point>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_at_c<adapted::point,0>::type
, mpl::front<adapted::point>::type>));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,88 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/adt/adapt_adt_named.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
class empty_adt{};
BOOST_FUSION_ADAPT_ADT_NAMED(::empty_adt,empty_adt,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
empty_adt empty;
{
BOOST_MPL_ASSERT((traits::is_view<adapted::empty_adt>));
BOOST_STATIC_ASSERT(traits::is_view<adapted::empty_adt>::value);
adapted::empty_adt e(empty);
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<adapted::empty_adt>::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<adapted::empty_adt>));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<adapted::empty_adt>::type,
fusion::result_of::end<adapted::empty_adt>::type>));
}
{
fusion::vector<> v;
adapted::empty_adt e(empty);
BOOST_TEST(v == e);
BOOST_TEST_NOT(v != e);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
adapted::empty_adt e(empty);
// conversion from empty_adt to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_adt to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<adapted::empty_adt>));
return boost::report_errors();
}

View File

@@ -0,0 +1,164 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/support.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct x_member;
struct y_member;
struct z_member;
struct non_member;
class point
{
public:
point() : x(0), y(0), z(0) {}
point(int in_x, int in_y, int in_z) : x(in_x), y(in_y), z(in_z) {}
int get_x() const { return x; }
int get_y() const { return y; }
int get_z() const { return z; }
void set_x(int x_) { x = x_; }
void set_y(int y_) { y = y_; }
void set_z(int z_) { z = z_; }
private:
int x;
int y;
int z;
};
}
#if BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_ADT(
ns::point,
(int, int, obj.get_x(), obj.set_x(val), ns::x_member)
(int, int, obj.get_y(), obj.set_y(val), ns::y_member)
(obj.get_z(), obj.set_z(val), ns::z_member)
)
#else // BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_ADT(
ns::point,
(int, int, obj.get_x(), obj.set_x(val), ns::x_member)
(int, int, obj.get_y(), obj.set_y(val), ns::y_member)
(auto, auto, obj.get_z(), obj.set_z(val), ns::z_member)
)
#endif
class empty_adt{};
BOOST_FUSION_ADAPT_ASSOC_ADT(empty_adt,)
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
BOOST_STATIC_ASSERT(!traits::is_view<ns::point>::value);
ns::point p(123, 456, 789);
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<ns::point>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<ns::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
{
boost::fusion::vector<int, float, int> v1(4, 2.f, 2);
ns::point v2(5, 3, 3);
boost::fusion::vector<long, double, int> 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 ns::point to vector
ns::point p(5, 3, 3);
boost::fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from ns::point to list
ns::point p(5, 3, 3);
boost::fusion::list<int, long, int> l(p);
l = p;
}
{
BOOST_MPL_ASSERT((boost::mpl::is_sequence<ns::point>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_at_c<ns::point,0>::type
, boost::mpl::front<ns::point>::type>));
}
{
// assoc stuff
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<ns::point, ns::x_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<ns::point, ns::y_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<ns::point, ns::z_member>));
BOOST_MPL_ASSERT((boost::mpl::not_<boost::fusion::result_of::has_key<ns::point, ns::non_member> >));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<ns::point, ns::x_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<ns::point, ns::y_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<ns::point, ns::z_member>::type, int>));
ns::point p(5, 3, 1);
BOOST_TEST(at_key<ns::x_member>(p) == 5);
BOOST_TEST(at_key<ns::y_member>(p) == 3);
BOOST_TEST(at_key<ns::z_member>(p) == 1);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,89 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
class empty_adt{};
BOOST_FUSION_ADAPT_ASSOC_ADT(empty_adt,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_adt>));
BOOST_STATIC_ASSERT(!traits::is_view<empty_adt>::value);
empty_adt e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_adt>::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_adt>));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<empty_adt>::type,
fusion::result_of::end<empty_adt>::type>));
}
{
fusion::vector<> v;
empty_adt e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(e != v);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
empty_adt e;
// conversion from empty_adt to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_adt to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_adt>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_adt, void>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_adt, int>));
return boost::report_errors();
}

View File

@@ -0,0 +1,159 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/support.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/adapted/adt/adapt_assoc_adt_named.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct x_member;
struct y_member;
struct z_member;
class point
{
public:
point() : x(0), y(0) {}
point(int in_x, int in_y) : x(in_x), y(in_y) {}
int get_x() const { return x; }
int get_y() const { return y; }
void set_x(int x_) { x = x_; }
void set_y(int y_) { y = y_; }
private:
int x;
int y;
};
}
#if BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(
ns::point,
point,
(obj.get_x(), obj.set_x(val), ns::x_member)
(int, int, obj.get_y(), obj.set_y(val), ns::y_member)
)
#else // BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(
ns::point,
point,
(auto, auto, obj.get_x(), obj.set_x(val), ns::x_member)
(int, int, obj.get_y(), obj.set_y(val), ns::y_member)
)
#endif
class empty_adt{};
BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(empty_adt, renamed_empty_adt,)
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT((traits::is_view<adapted::point>));
BOOST_STATIC_ASSERT(traits::is_view<adapted::point>::value);
ns::point basep(123, 456);
adapted::point p(basep);
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(boost::fusion::result_of::size<adapted::point>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<adapted::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
}
{
boost::fusion::vector<int, float> v1(4, 2.f);
ns::point basev2(5, 3);
adapted::point v2(basev2);
boost::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 adapted::point to vector
ns::point basep(5, 3);
adapted::point p(basep);
boost::fusion::vector<int, long> v(p);
v = p;
}
{
// conversion from adated::point to list
ns::point basep(5, 3);
adapted::point p(basep);
boost::fusion::list<int, long> l(p);
l = p;
}
{
BOOST_MPL_ASSERT((boost::mpl::is_sequence<adapted::point>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_at_c<adapted::point,0>::type
, boost::mpl::front<adapted::point>::type>));
}
{
// assoc stuff
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<adapted::point, ns::x_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<adapted::point, ns::y_member>));
BOOST_MPL_ASSERT((boost::mpl::not_<boost::fusion::result_of::has_key<adapted::point, ns::z_member> >));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<adapted::point, ns::x_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<adapted::point, ns::y_member>::type, int>));
ns::point basep(5, 3);
adapted::point p(basep);
BOOST_TEST(at_key<ns::x_member>(p) == 5);
BOOST_TEST(at_key<ns::y_member>(p) == 3);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,90 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/adt/adapt_assoc_adt_named.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
class empty_adt{};
BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(::empty_adt,empty_adt,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
empty_adt empty;
{
BOOST_MPL_ASSERT((traits::is_view<adapted::empty_adt>));
BOOST_STATIC_ASSERT(traits::is_view<adapted::empty_adt>::value);
adapted::empty_adt e(empty);
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<adapted::empty_adt>::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<adapted::empty_adt>));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<adapted::empty_adt>::type,
fusion::result_of::end<adapted::empty_adt>::type>));
}
{
fusion::vector<> v;
adapted::empty_adt e(empty);
BOOST_TEST(v == e);
BOOST_TEST_NOT(e != v);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
adapted::empty_adt e(empty);
// conversion from empty_adt to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_adt to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<adapted::empty_adt>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<adapted::empty_adt, void>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<adapted::empty_adt, int>));
return boost::report_errors();
}

View File

@@ -0,0 +1,168 @@
/*=============================================================================
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.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/container/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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/back.hpp>
#include <boost/mpl/is_sequence.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 non_member;
struct point
{
int x;
int y;
int z;
};
}
#if BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_STRUCT(
ns::point,
(x, ns::x_member)
(auto, y, ns::y_member)
(int, z, ns::z_member)
)
#else // BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_STRUCT(
ns::point,
(auto, x, ns::x_member)
(auto, y, ns::y_member)
(int, z, ns::z_member)
)
#endif
struct empty_struct {};
BOOST_FUSION_ADAPT_ASSOC_STRUCT(empty_struct,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
BOOST_STATIC_ASSERT(!traits::is_view<ns::point>::value);
ns::point p = {123, 456, 789};
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<ns::point>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<ns::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
{
fusion::vector<int, float, int> v1(4, 2.f, 2);
ns::point v2 = {5, 3, 3};
fusion::vector<long, double, int> 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 ns::point to vector
ns::point p = {5, 3, 3};
fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from ns::point to list
ns::point p = {5, 3, 3};
fusion::list<int, long, int> l(p);
l = p;
}
{
// assoc stuff
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<ns::point, ns::x_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<ns::point, ns::y_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<ns::point, ns::z_member>));
BOOST_MPL_ASSERT((mpl::not_<boost::fusion::result_of::has_key<ns::point, ns::non_member> >));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<ns::point, ns::x_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<ns::point, ns::y_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<ns::point, ns::z_member>::type, int>));
ns::point p = {5, 3, 9};
BOOST_TEST(at_key<ns::x_member>(p) == 5);
BOOST_TEST(at_key<ns::y_member>(p) == 3);
BOOST_TEST(at_key<ns::z_member>(p) == 9);
}
{
BOOST_MPL_ASSERT((mpl::is_sequence<ns::point>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_at_c<ns::point,0>::type
, mpl::front<ns::point>::type>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_at_c<ns::point,2>::type
, mpl::back<ns::point>::type>));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,89 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
class empty_struct{};
BOOST_FUSION_ADAPT_ASSOC_STRUCT(empty_struct,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
BOOST_STATIC_ASSERT(!traits::is_view<empty_struct>::value);
empty_struct e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_struct>));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<empty_struct>::type,
fusion::result_of::end<empty_struct>::type>));
}
{
fusion::vector<> v;
empty_struct e;
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
empty_struct e;
// conversion from empty_struct to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_struct to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct, void>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct, int>));
return boost::report_errors();
}

View File

@@ -0,0 +1,139 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/support.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/not.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct x_member;
struct y_member;
struct z_member;
struct point
{
int x;
int y;
};
}
#if BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(
ns::point,
point,
(x, ns::x_member)
(auto, y, ns::y_member)
)
#else // BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(
ns::point,
point,
(int, x, ns::x_member)
(auto, y, ns::y_member)
)
#endif
struct empty_struct {};
BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(empty_struct, renamed_empty_struct,)
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT((traits::is_view<adapted::point>));
BOOST_STATIC_ASSERT(traits::is_view<adapted::point>::value);
ns::point basep = {123, 456};
adapted::point p(basep);
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(boost::fusion::result_of::size<adapted::point>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<adapted::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
}
{
vector<int, float> v1(4, 2.f);
ns::point basev2 = {5, 3};
adapted::point v2(basev2);
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 adapted::point to vector
ns::point basep = {5, 3};
adapted::point p(basep);
vector<int, long> v(p);
v = p;
}
{
// conversion from adapted::point to list
ns::point basep = {5, 3};
adapted::point p(basep);
list<int, long> l(p);
l = p;
}
{
// assoc stuff
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<adapted::point, ns::x_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<adapted::point, ns::y_member>));
BOOST_MPL_ASSERT((boost::mpl::not_<boost::fusion::result_of::has_key<adapted::point, ns::z_member> >));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<adapted::point, ns::x_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<adapted::point, ns::y_member>::type, int>));
ns::point basep = {5, 3};
adapted::point p(basep);
BOOST_TEST(at_key<ns::x_member>(p) == 5);
BOOST_TEST(at_key<ns::y_member>(p) == 3);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,90 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/adapt_assoc_struct_named.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
class empty_struct{};
BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(::empty_struct,empty_struct,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
empty_struct empty;
{
BOOST_MPL_ASSERT((traits::is_view<adapted::empty_struct>));
BOOST_STATIC_ASSERT(traits::is_view<adapted::empty_struct>::value);
adapted::empty_struct e(empty);
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<adapted::empty_struct>::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<adapted::empty_struct>));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<adapted::empty_struct>::type,
fusion::result_of::end<adapted::empty_struct>::type>));
}
{
fusion::vector<> v;
adapted::empty_struct e(empty);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
adapted::empty_struct e(empty);
// conversion from empty_struct to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_struct to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<adapted::empty_struct>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<adapted::empty_struct, void>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<adapted::empty_struct, int>));
return boost::report_errors();
}

View File

@@ -0,0 +1,177 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/support.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct x_member;
struct y_member;
struct z_member;
struct non_member;
template<typename X, typename Y, typename Z>
class point
{
public:
point() : x(0), y(0), z(0) {}
point(X in_x, Y in_y, Z in_z) : x(in_x), y(in_y), z(in_z) {}
X get_x() const { return x; }
Y get_y() const { return y; }
Z get_z() const { return z; }
void set_x(X x_) { x = x_; }
void set_y(Y y_) { y = y_; }
void set_z(Z z_) { z = z_; }
private:
X x;
Y y;
Z z;
};
}
#if BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_TPL_ADT(
(X)(Y)(Z),
(ns::point)(X)(Y)(Z),
(X, X, obj.get_x(), obj.set_x(val), ns::x_member)
(Y, Y, obj.get_y(), obj.set_y(val), ns::y_member)
(obj.get_z(), obj.set_z(val), ns::z_member)
)
#else // BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_TPL_ADT(
(X)(Y)(Z),
(ns::point)(X)(Y)(Z),
(X, X, obj.get_x(), obj.set_x(val), ns::x_member)
(Y, Y, obj.get_y(), obj.set_y(val), ns::y_member)
(auto, auto, obj.get_z(), obj.set_z(val), ns::z_member)
)
#endif
template <typename TypeToConstruct>
class empty_adt_templated_factory {
TypeToConstruct operator()() {
return TypeToConstruct();
}
};
BOOST_FUSION_ADAPT_ASSOC_TPL_ADT(
(TypeToConstruct),
(empty_adt_templated_factory)(TypeToConstruct),
)
int
main()
{
using namespace boost::fusion;
typedef ns::point<int,int,long> point;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
BOOST_STATIC_ASSERT(!traits::is_view<point>::value);
point p(123, 456, 789);
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
{
boost::fusion::vector<int, float, long> v1(4, 2.f, 2);
point v2(5, 3, 3);
boost::fusion::vector<long, double, long> 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 point to vector
point p(5, 3, 3);
boost::fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from point to list
point p(5, 3, 3);
boost::fusion::list<int, long, int> l(p);
l = p;
}
{
BOOST_MPL_ASSERT((boost::mpl::is_sequence<point>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_at_c<point,0>::type
, boost::mpl::front<point>::type>));
}
{
// assoc stuff
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<point, ns::x_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<point, ns::y_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<point, ns::z_member>));
BOOST_MPL_ASSERT((boost::mpl::not_<boost::fusion::result_of::has_key<point, ns::non_member> >));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<point, ns::x_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<point, ns::y_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<point, ns::z_member>::type, long>));
point p(5, 3, 1);
BOOST_TEST(at_key<ns::x_member>(p) == 5);
BOOST_TEST(at_key<ns::y_member>(p) == 3);
BOOST_TEST(at_key<ns::z_member>(p) == 1);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,89 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
template <typename T>
class empty_adt{};
BOOST_FUSION_ADAPT_ASSOC_TPL_ADT((T), (empty_adt)(T),)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_adt<void> >));
empty_adt<void> e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_adt<void> >::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_adt<void> >));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<empty_adt<void> >::type,
fusion::result_of::end<empty_adt<void> >::type>));
}
{
fusion::vector<> v;
empty_adt<void> e;
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
empty_adt<void> e;
// conversion from empty_adt to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_adt to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_adt<void> >));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_adt<void>, void>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_adt<void>, int>));
return boost::report_errors();
}

View File

@@ -0,0 +1,168 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/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/container/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 <boost/static_assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct x_member;
struct y_member;
struct z_member;
struct non_member;
template<typename X, typename Y, typename Z>
struct point
{
X x;
Y y;
Z z;
};
}
#if BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT(
(X)(Y)(Z),
(ns::point)(X)(Y)(Z),
(int, x, ns::x_member)
(auto, y, ns::y_member)
(z, ns::z_member)
)
#else // BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT(
(X)(Y)(Z),
(ns::point)(X)(Y)(Z),
(int, x, ns::x_member)
(Y, y, ns::y_member)
(auto, z, ns::z_member)
)
#endif
template <typename TypeToConstruct>
struct empty_struct_templated_factory {
TypeToConstruct operator()() {
return TypeToConstruct();
}
};
BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT(
(TypeToConstruct),
(empty_struct_templated_factory)(TypeToConstruct),
)
int
main()
{
using namespace boost::fusion;
typedef ns::point<int,int,float> point;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
BOOST_STATIC_ASSERT(!traits::is_view<point>::value);
point p = {123, 456, 789.43f};
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789.43f));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
{
vector<int, float, int> v1(4, 2.f, 2);
point v2 = {5, 3, 3.f};
vector<long, double, float> v3(5, 4., 4.13f);
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 point to vector
point p = {5, 3, 3.f};
vector<int, long, int> v(p);
v = p;
}
{
// conversion from point to list
point p = {5, 3, 3.f};
list<int, long, int> l(p);
l = p;
}
{
// assoc stuff
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<point, ns::x_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<point, ns::y_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<point, ns::z_member>));
BOOST_MPL_ASSERT((boost::mpl::not_<boost::fusion::result_of::has_key<point, ns::non_member> >));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<point, ns::x_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<point, ns::y_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<point, ns::z_member>::type, float>));
point p = {5, 3, 9.f};
BOOST_TEST(at_key<ns::x_member>(p) == 5);
BOOST_TEST(at_key<ns::y_member>(p) == 3);
BOOST_TEST(at_key<ns::z_member>(p) == 9);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,89 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
template <typename T>
class empty_struct{};
BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT((T), (empty_struct)(T),)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
empty_struct<void> e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_struct<void> >));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<empty_struct<void> >::type,
fusion::result_of::end<empty_struct<void> >::type>));
}
{
fusion::vector<> v;
empty_struct<void> e;
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
empty_struct<void> e;
// conversion from empty_struct to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_struct to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct<void>, void>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct<void>, int>));
return boost::report_errors();
}

View File

@@ -0,0 +1,271 @@
/*=============================================================================
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/intrinsic/value_at.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/container/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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
namespace namespaced_type {
typedef int integer;
}
namespace ns
{
struct point
{
int x;
int y;
namespaced_type::integer z;
};
#if !BOOST_WORKAROUND(__GNUC__,<4)
struct point_with_private_attributes
{
friend struct boost::fusion::extension::access;
private:
int x;
int y;
int z;
public:
point_with_private_attributes(int x, int y, int z):x(x),y(y),z(z)
{}
};
#endif
struct foo
{
int x;
};
struct bar
{
foo foo_;
int y;
};
// Testing non-constexpr compatible types
struct employee {
std::string name;
std::string nickname;
employee(std::string name, std::string nickname)
: name(name), nickname(nickname)
{}
};
}
#if BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_STRUCT(
ns::point,
x,
y,
z
)
# if !BOOST_WORKAROUND(__GNUC__,<4)
BOOST_FUSION_ADAPT_STRUCT(
ns::point_with_private_attributes,
x,
y,
z
)
# endif
struct s { int m; };
BOOST_FUSION_ADAPT_STRUCT(s, m)
BOOST_FUSION_ADAPT_STRUCT(
ns::bar,
foo_.x, // test that adapted members can actually be expressions
(auto , y)
)
BOOST_FUSION_ADAPT_STRUCT(
ns::employee,
name,
nickname
)
#else // BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_STRUCT(
ns::point,
(int, x)
(auto, y)
(namespaced_type::integer, z)
)
# if !BOOST_WORKAROUND(__GNUC__,<4)
BOOST_FUSION_ADAPT_STRUCT(
ns::point_with_private_attributes,
(int, x)
(int, y)
(auto, z)
)
# endif
struct s { int m; };
BOOST_FUSION_ADAPT_STRUCT(s, (auto, m))
BOOST_FUSION_ADAPT_STRUCT(
ns::bar,
(auto, foo_.x) // test that adapted members can actually be expressions
(BOOST_FUSION_ADAPT_AUTO, y) // Mixing auto & BOOST_FUSION_ADAPT_AUTO
// to test backward compatibility
)
BOOST_FUSION_ADAPT_STRUCT(
ns::employee,
(std::string, name)
(BOOST_FUSION_ADAPT_AUTO, nickname)
)
#endif
struct empty_struct {};
BOOST_FUSION_ADAPT_STRUCT(empty_struct,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
using ns::point;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
BOOST_STATIC_ASSERT(!traits::is_view<point>::value);
point p = {123, 456, 789};
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
{
vector<int, float, int> v1(4, 2.f, 2);
point v2 = {5, 3, 3};
vector<long, double, int> 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 point to vector
point p = {5, 3, 3};
vector<int, long, int> v(p);
v = p;
}
{
// conversion from point to list
point p = {5, 3, 3};
list<int, long, int> l(p);
l = p;
}
{ // begin/end
using namespace boost::fusion;
using boost::is_same;
typedef boost::fusion::result_of::begin<s>::type b;
typedef boost::fusion::result_of::end<s>::type e;
// this fails
BOOST_MPL_ASSERT((is_same<boost::fusion::result_of::next<b>::type, e>));
}
{
BOOST_MPL_ASSERT((mpl::is_sequence<ns::point>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_at_c<ns::point,0>::type
, mpl::front<ns::point>::type>));
}
#if !BOOST_WORKAROUND(__GNUC__,<4)
{
ns::point_with_private_attributes p(123, 456, 789);
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
}
#endif
{
fusion::vector<int, float> v1(4, 2.f);
ns::bar v2 = {{5}, 3};
BOOST_TEST(v1 < v2);
BOOST_TEST(v1 <= v2);
BOOST_TEST(v2 > v1);
BOOST_TEST(v2 >= v1);
}
{
ns::employee emp("John Doe", "jdoe");
std::cout << at_c<0>(emp) << std::endl;
std::cout << at_c<1>(emp) << std::endl;
fusion::vector<std::string, std::string> v1("John Doe", "jdoe");
BOOST_TEST(emp == v1);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,87 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
class empty_struct{};
BOOST_FUSION_ADAPT_STRUCT(empty_struct,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
BOOST_STATIC_ASSERT(!traits::is_view<empty_struct>::value);
empty_struct e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_struct>));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<empty_struct>::type,
fusion::result_of::end<empty_struct>::type>));
}
{
fusion::vector<> v;
empty_struct e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(e != v);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
empty_struct e;
// conversion from empty_struct to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_struct to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>));
return boost::report_errors();
}

View File

@@ -0,0 +1,164 @@
/*=============================================================================
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_named.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/value_at.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/container/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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct point
{
int x;
int y;
int z;
};
}
#if BOOST_PP_VARIADICS
// this creates a fusion view: boost::fusion::adapted::point
BOOST_FUSION_ADAPT_STRUCT_NAMED(
ns::point, point,
x,
y,
z
)
// this creates a fusion view: ns1::s1
struct s { int m; };
BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(s, (ns1), s1, m)
#else // BOOST_PP_VARIADICS
// this creates a fusion view: boost::fusion::adapted::point
BOOST_FUSION_ADAPT_STRUCT_NAMED(
ns::point, point,
(int, x)
(BOOST_FUSION_ADAPT_AUTO, y)
(auto, z)
)
// this creates a fusion view: ns1::s1
struct s { int m; };
BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(s, (ns1), s1, (auto, m))
#endif
struct empty_struct {};
BOOST_FUSION_ADAPT_STRUCT_NAMED(empty_struct, renamed_empty_struct, )
BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(empty_struct, (ns1), renamed_empty_struct1, )
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT((traits::is_view<adapted::point>));
BOOST_STATIC_ASSERT(traits::is_view<adapted::point>::value);
ns::point basep = {123, 456, 789};
adapted::point p(basep);
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<adapted::point>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<adapted::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
{
fusion::vector<int, float, int> v1(4, 2.f, 2);
ns::point p = {5, 3, 3};
adapted::point v2(p);
fusion::vector<long, double, int> 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 adapted::point to vector
ns::point basep = {5, 3, 3};
adapted::point p(basep);
fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from adapted::point to list
ns::point basep = {5, 3, 3};
adapted::point p(basep);
fusion::list<int, long, int> l(p);
l = p;
}
{ // begin/end
using namespace boost::fusion;
using boost::is_same;
typedef boost::fusion::result_of::begin<ns1::s1>::type b;
typedef boost::fusion::result_of::end<ns1::s1>::type e;
// this fails
BOOST_MPL_ASSERT((is_same<boost::fusion::result_of::next<b>::type, e>));
}
{
BOOST_MPL_ASSERT((mpl::is_sequence<adapted::point>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_at_c<adapted::point,0>::type
, mpl::front<adapted::point>::type>));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,88 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/adapt_struct_named.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
class empty_struct{};
BOOST_FUSION_ADAPT_STRUCT_NAMED(::empty_struct,empty_struct,)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
empty_struct empty;
{
BOOST_MPL_ASSERT((traits::is_view<adapted::empty_struct>));
BOOST_STATIC_ASSERT(traits::is_view<adapted::empty_struct>::value);
adapted::empty_struct e(empty);
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<adapted::empty_struct>::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<adapted::empty_struct>));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<adapted::empty_struct>::type,
fusion::result_of::end<adapted::empty_struct>::type>));
}
{
fusion::vector<> v;
adapted::empty_struct e(empty);
BOOST_TEST(v == e);
BOOST_TEST_NOT(e != v);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
adapted::empty_struct e(empty);
// conversion from empty_struct to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_struct to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<adapted::empty_struct>));
return boost::report_errors();
}

View File

@@ -0,0 +1,182 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/adt/adapt_adt.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/value_at.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/container/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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
template<typename X, typename Y>
class point
{
public:
point() : x(0), y(0), z(0) {}
point(X x_, Y y_, int z_) : x(x_), y(y_), z(z_) {}
X get_x() const { return x; }
Y get_y() const { return y; }
int get_z() const { return z; }
void set_x(X x_) { x = x_; }
void set_y(Y y_) { y = y_; }
void set_z(int z_) { z = z_; }
private:
X x;
Y y;
int z;
};
}
#if BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_TPL_ADT(
(X)(Y),
(ns::point)(X)(Y),
(X, X, obj.get_x(), obj.set_x(val))
(Y, Y, obj.get_y(), obj.set_y(val))
(obj.get_z(), obj.set_z(val))
)
#else // BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_TPL_ADT(
(X)(Y),
(ns::point)(X)(Y),
(X, X, obj.get_x(), obj.set_x(val))
(Y, Y, obj.get_y(), obj.set_y(val))
(auto, auto, obj.get_z(), obj.set_z(val))
)
#endif
template <typename TypeToConstruct>
class empty_adt_templated_factory {
TypeToConstruct operator()() {
return TypeToConstruct();
}
};
BOOST_FUSION_ADAPT_TPL_ADT(
(TypeToConstruct),
(empty_adt_templated_factory)(TypeToConstruct),
)
int
main()
{
using namespace boost::fusion;
typedef ns::point<int, int> point;
typedef ns::point<std::string, std::string> name;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
BOOST_STATIC_ASSERT(!traits::is_view<point>::value);
point p(123, 456, 789);
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
{
boost::fusion::vector<int, float, int> v1(4, 2.f, 2);
point v2(5, 3, 3);
boost::fusion::vector<long, double, int> 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);
}
{
boost::fusion::vector<std::string, std::string, int> v1("Lincoln", "Abraham", 3);
name v2("Roosevelt", "Franklin", 3);
name v3("Roosevelt", "Theodore", 3);
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 point to vector
point p(5, 3, 3);
boost::fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from point to list
point p(5, 3, 3);
boost::fusion::list<int, long, int> l(p);
l = p;
}
{
BOOST_MPL_ASSERT((boost::mpl::is_sequence<point>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_at_c<point,0>::type
, boost::mpl::front<point>::type>));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,87 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/adt/adapt_adt.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
template <typename T>
class empty_adt{};
BOOST_FUSION_ADAPT_TPL_ADT((T), (empty_adt)(T),)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_adt<void> >));
empty_adt<void> e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_adt<void> >::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_adt<void> >));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<empty_adt<void> >::type,
fusion::result_of::end<empty_adt<void> >::type>));
}
{
fusion::vector<> v;
empty_adt<void> e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(v != e);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(e > v);
BOOST_TEST(e >= v);
}
{
empty_adt<void> e;
// conversion from empty_adt to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_adt to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_adt<void> >));
return boost::report_errors();
}

View File

@@ -0,0 +1,159 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/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/container/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/static_assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
template<typename X, typename Y>
struct point
{
X x;
Y y;
int z;
};
}
#if BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_TPL_STRUCT(
(X)(Y),
(ns::point)(X)(Y),
x,
(auto, y)
(int, z)
)
template<typename M>
struct s { M m; };
BOOST_FUSION_ADAPT_TPL_STRUCT((M), (s)(M), m)
#else // BOOST_PP_VARIADICS
BOOST_FUSION_ADAPT_TPL_STRUCT(
(X)(Y),
(ns::point)(X)(Y),
(X, x)
(Y, y)
(auto, z)
)
template<typename M>
struct s { M m; };
BOOST_FUSION_ADAPT_TPL_STRUCT((M), (s)(M), (auto, m))
#endif
template <typename TypeToConstruct>
struct empty_struct_templated_factory {
TypeToConstruct operator()() {
return TypeToConstruct();
}
};
BOOST_FUSION_ADAPT_TPL_STRUCT(
(TypeToConstruct),
(empty_struct_templated_factory)(TypeToConstruct),
)
int
main()
{
using namespace boost::fusion;
typedef ns::point<int, int> point;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
BOOST_STATIC_ASSERT(!traits::is_view<point>::value);
point p = {123, 456, 789};
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
std::cout << at_c<2>(p) << std::endl;
std::cout << p << std::endl;
BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
at_c<2>(p) = 12;
BOOST_TEST(p == make_vector(6, 9, 12));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 3);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 12);
}
{
vector<int, float, int> v1(4, 2.f, 2);
point v2 = {5, 3, 3};
vector<long, double, int> 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 point to vector
point p = {5, 3, 3};
vector<int, long, int> v(p);
v = p;
}
{
// conversion from point to list
point p = {5, 3, 3};
list<int, long> l(p);
l = p;
}
{ // begin/end
using namespace boost::fusion;
typedef boost::fusion::result_of::begin<s<int> >::type b;
typedef boost::fusion::result_of::end<s<int> >::type e;
// this fails
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::next<b>::type, e>));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,87 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_vector.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/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
template <typename T>
class empty_struct{};
BOOST_FUSION_ADAPT_TPL_STRUCT((T), (empty_struct)(T),)
int
main()
{
using namespace boost::fusion;
using namespace boost;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
empty_struct<void> e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
BOOST_MPL_ASSERT((fusion::result_of::empty<empty_struct<void> >));
BOOST_MPL_ASSERT((fusion::result_of::equal_to<
fusion::result_of::begin<empty_struct<void> >::type,
fusion::result_of::end<empty_struct<void> >::type>));
}
{
fusion::vector<> v;
empty_struct<void> e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(v != e);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(v > e);
BOOST_TEST(v >= e);
}
{
empty_struct<void> e;
// conversion from empty_struct to vector
fusion::vector<> v(e);
v = e;
// FIXME
// conversion from empty_struct to list
//fusion::list<> l(e);
//l = e;
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
return boost::report_errors();
}

View File

@@ -0,0 +1,189 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/core/lightweight_test.hpp>
#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <iostream>
#include <string>
namespace fusion=boost::fusion;
template<typename Name, typename Age>
struct employee
{
private:
Name name;
Age age;
public:
template<typename OtherName>
void
set_name(OtherName const& n)
{
name=n;
}
template<typename OtherAge>
void
set_age(OtherAge const& a)
{
age=a;
}
Name& get_name()
{
return name;
}
Name const& get_name()const
{
return name;
}
Age& get_age()
{
return age;
}
Age const& get_age()const
{
return age;
}
};
namespace keys
{
struct name;
struct age;
}
BOOST_FUSION_ADAPT_ASSOC_TPL_ADT(
(Name)(Age),
(employee) (Name)(Age),
(Name&, Name const&, obj.get_name(), obj.template set_name<Val>(val), keys::name)
(Age&, Age const&, obj.get_age(), obj.template set_age<Val>(val), keys::age))
int main()
{
typedef employee<std::string, int> et;
typedef et const etc;
et e;
etc& ec=e;
fusion::at_key<keys::name>(e)="marshall mathers";
fusion::at_key<keys::age>(e)=37;
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::value_at_key<et, keys::name>::type,
std::string
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::value_at_key<et, keys::name>::type,
boost::fusion::result_of::value_at_c<et, 0>::type
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::value_at_key<et, keys::age>::type,
int
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::value_at_key<et, keys::age>::type,
boost::fusion::result_of::value_at_c<et, 1>::type
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::at_key<et, keys::name>::type,
fusion::extension::adt_attribute_proxy<et, 0, false>
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::at_key<et, keys::age>::type,
fusion::extension::adt_attribute_proxy<et, 1, false>
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::at_key<et, keys::name>::type,
boost::fusion::result_of::front<et>::type
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::at_key<et, keys::age>::type,
boost::fusion::result_of::back<et>::type
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::at_key<etc, keys::name>::type,
fusion::extension::adt_attribute_proxy<et, 0, true>
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::at_key<etc, keys::age>::type,
fusion::extension::adt_attribute_proxy<et, 1, true>
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::at_key<etc, keys::name>::type,
boost::fusion::result_of::front<etc>::type
>));
BOOST_MPL_ASSERT((
boost::is_same<
boost::fusion::result_of::at_key<etc, keys::age>::type,
boost::fusion::result_of::back<etc>::type
>));
BOOST_MPL_ASSERT((
boost::is_same<
fusion::extension::adt_attribute_proxy<et, 0, false>::type,
std::string&
>));
BOOST_MPL_ASSERT((
boost::is_same<
fusion::extension::adt_attribute_proxy<et, 0, true>::type,
std::string const&
>));
BOOST_MPL_ASSERT((
boost::is_same<
fusion::extension::adt_attribute_proxy<et, 1, false>::type,
int&
>));
BOOST_MPL_ASSERT((
boost::is_same<
fusion::extension::adt_attribute_proxy<et, 1, true>::type,
int const&
>));
{
std::string& name=fusion::at_key<keys::name>(e);
int& age=fusion::at_key<keys::age>(e);
BOOST_TEST(name=="marshall mathers");
BOOST_TEST(age==37);
BOOST_TEST(fusion::at_key<keys::name>(e).get()=="marshall mathers");
BOOST_TEST(fusion::at_key<keys::age>(e).get()==37);
BOOST_TEST(fusion::front(e).get()=="marshall mathers");
BOOST_TEST(fusion::back(e).get()==37);
}
{
std::string const& name=fusion::at_key<keys::name>(ec);
int const& age=fusion::at_key<keys::age>(ec);
BOOST_TEST(name=="marshall mathers");
BOOST_TEST(age==37);
BOOST_TEST(fusion::at_key<keys::name>(ec).get()=="marshall mathers");
BOOST_TEST(fusion::at_key<keys::age>(ec).get()==37);
BOOST_TEST(fusion::front(ec).get()=="marshall mathers");
BOOST_TEST(fusion::back(ec).get()==37);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,41 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/array.hpp>
#include <boost/fusion/sequence/intrinsic.hpp>
#include <boost/fusion/iterator.hpp>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/mpl/assert.hpp>
int main()
{
using namespace boost::fusion;
typedef int array_type[3];
BOOST_MPL_ASSERT((traits::is_sequence<array_type>));
BOOST_MPL_ASSERT_NOT((traits::is_view<array_type>));
BOOST_STATIC_ASSERT(traits::is_sequence<array_type>::value);
BOOST_STATIC_ASSERT(!traits::is_view<array_type>::value);
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();
}

View File

@@ -0,0 +1,70 @@
/*=============================================================================
Copyright (c) 2014 Louis Dionne
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/algorithm/transformation/push_back.hpp>
#include <boost/fusion/algorithm/transformation/push_front.hpp>
#include <boost/fusion/container/deque/convert.hpp>
#include <boost/fusion/container/deque/deque.hpp>
#include <boost/fusion/container/generation/make_deque.hpp>
#include <boost/fusion/container/generation/make_list.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <string>
int main() {
using namespace boost::fusion;
using namespace boost;
BOOST_TEST(as_deque(make_vector()) == make_deque());
BOOST_TEST(as_deque(make_vector(1)) == make_deque(1));
BOOST_TEST(as_deque(make_vector(1, '2')) == make_deque(1, '2'));
BOOST_TEST(as_deque(make_vector(1, '2', 3.3f)) == make_deque(1, '2', 3.3f));
BOOST_TEST(as_deque(make_list()) == make_deque());
BOOST_TEST(as_deque(make_list(1)) == make_deque(1));
BOOST_TEST(as_deque(make_list(1, '2')) == make_deque(1, '2'));
BOOST_TEST(as_deque(make_list(1, '2', 3.3f)) == make_deque(1, '2', 3.3f));
{
deque<> xs;
BOOST_TEST(as_deque(push_back(xs, 1)) == make_deque(1));
}
{
deque<int> xs(1);
BOOST_TEST(as_deque(push_back(xs, '2')) == make_deque(1, '2'));
}
{
deque<int, char> xs(1, '2');
BOOST_TEST(as_deque(push_back(xs, 3.3f)) == make_deque(1, '2', 3.3f));
}
{
deque<> xs;
BOOST_TEST(
as_deque(push_front(xs, make_deque(1, '2', 3.3f))) ==
make_deque(make_deque(1, '2', 3.3f))
);
BOOST_TEST(as_deque(make_deque(make_deque(1))) == make_deque(make_deque(1)));
}
/* Disabling test for now, see https://github.com/boostorg/fusion/pull/38 ($$$ FIXME $$$)
{
deque<> xs;
BOOST_TEST(
as_deque(push_front(xs, make_vector(1, '2', 3.3f))) ==
make_deque(make_vector(1, '2', 3.3f))
);
}
*/
return boost::report_errors();
}

View File

@@ -0,0 +1,53 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/container/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();
}

View File

@@ -0,0 +1,61 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/container/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;
boost::fusion::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();
}

View File

@@ -0,0 +1,85 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/container/map/convert.hpp>
#include <boost/fusion/container/generation/make_set.hpp>
#include <boost/fusion/container/vector/convert.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>
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;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
ns::point p = {123, 456};
std::cout << as_map(p) << std::endl;
}
{
ns::point p = {123, 456};
boost::fusion::result_of::as_map<ns::point>::type map(p);
std::cout << at_key<ns::x_member>(map) << std::endl;
std::cout << at_key<ns::y_member>(map) << std::endl;
BOOST_TEST(at_key<ns::x_member>(map) == 123);
BOOST_TEST(at_key<ns::y_member>(map) == 456);
}
{
boost::fusion::result_of::as_map<set<int, char> >::type map(make_set(1, '2'));
BOOST_TEST(at_key<int>(map) == 1);
BOOST_TEST(at_key<char>(map) == '2');
}
{
// test conversion
typedef map<
pair<ns::x_member, int>
, pair<ns::y_member, int> >
map_type;
ns::point p = {123, 456};
map_type m(p);
BOOST_TEST(as_vector(m) == make_vector(make_pair<ns::x_member>(123), make_pair<ns::y_member>(456)));
m = (make_vector(make_pair<ns::x_member>(123), make_pair<ns::y_member>(456))); // test assign
BOOST_TEST(as_vector(m) == make_vector(make_pair<ns::x_member>(123), make_pair<ns::y_member>(456)));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,64 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/container/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));
}
{
boost::fusion::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();
}

View File

@@ -0,0 +1,54 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/container/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();
}

View File

@@ -0,0 +1,114 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/deque/deque.hpp>
#include <boost/fusion/container/deque/back_extended_deque.hpp>
#include <boost/fusion/sequence/comparison.hpp>
#include <boost/fusion/container/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<> initial_deque_type;
initial_deque_type initial_deque;
typedef back_extended_deque<initial_deque_type, long> extended_type;
extended_type extended(initial_deque, 101L);
BOOST_TEST(size(extended) == 1);
BOOST_TEST(extended == make_vector(101L));
BOOST_TEST(*begin(extended) == 101L);
BOOST_TEST(*prior(end(extended)) == 101L);
BOOST_TEST(distance(begin(extended), end(extended)) == 1);
}
{
namespace mpl = boost::mpl;
typedef deque<> 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, long>));
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<mpl::begin<extended_type>::type>::type, long>));
BOOST_MPL_ASSERT((mpl::equal_to<mpl::size<extended_type>::type, mpl::int_<1> >));
}
{
long l(101L);
typedef deque<> initial_deque_type;
initial_deque_type initial_deque;
typedef back_extended_deque<initial_deque_type, long&> extended_type;
extended_type extended(initial_deque, l);
BOOST_TEST(extended == make_vector(101L));
long l2(202L);
extended_type extended2(initial_deque_type(), l2);
extended = extended2;
BOOST_TEST(extended == make_vector(202L));
BOOST_TEST(l == l2);
}
{
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();
}

View File

@@ -0,0 +1,44 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/boost_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>));
BOOST_STATIC_ASSERT(traits::is_sequence<array_type>::value);
BOOST_STATIC_ASSERT(!traits::is_view<array_type>::value);
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();
}

View File

@@ -0,0 +1,118 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/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/iterator/distance.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/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/sequence/convert.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/fusion/support/is_view.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/assert.hpp>
#include <iostream>
#include <string>
int
main()
{
using namespace boost::fusion;
using namespace boost;
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>));
BOOST_STATIC_ASSERT(!traits::is_view<tuple_type>::value);
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(boost::fusion::result_of::size<tuple_type>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::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!!!");
}
{
// conversion vector to boost tuple
boost::tuple<int, std::string> t = convert<boost_tuple_tag>(make_vector(123, "Hola!!!"));
BOOST_TEST(get<0>(t) == 123);
BOOST_TEST(get<1>(t) == "Hola!!!");
}
{
// test from Ticket #1601, submitted by Shunsuke Sogame
// expanded by Stjepan Rajko
boost::tuple<int, char> t(3, 'a');
BOOST_TEST(0u == fusion::distance(fusion::begin(t), fusion::begin(t)));
BOOST_TEST(1u == fusion::distance(fusion::begin(t), fusion::next(fusion::begin(t))));
BOOST_TEST(2u == fusion::distance(fusion::begin(t), fusion::end(t)));
}
{
typedef boost::tuple<int, std::string> tuple_type;
BOOST_MPL_ASSERT((mpl::is_sequence<tuple_type>));
BOOST_MPL_ASSERT((boost::is_same<int, mpl::front<tuple_type>::type>));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 2014 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/adapted/boost_tuple.hpp>
#define FUSION_SEQUENCE boost::tuple
#define FUSION_TRAVERSAL_TAG forward_traversal_tag
#define FUSION_NO_PRIOR
#include "./iterator.hpp"
int
main()
{
test();
return boost::report_errors();
}

View File

@@ -0,0 +1,79 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence/comparison.hpp>
struct not_a_fusion_container {};
template <typename T>
inline bool operator==(not_a_fusion_container, T const&) { return true; }
template <typename T>
inline bool operator!=(not_a_fusion_container, T const&) { return true; }
template <typename T>
inline bool operator<(not_a_fusion_container, T const&) { return true; }
template <typename T>
inline bool operator<=(not_a_fusion_container, T const&) { return true; }
template <typename T>
inline bool operator>(not_a_fusion_container, T const&) { return true; }
template <typename T>
inline bool operator>=(not_a_fusion_container, T const&) { return true; }
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));
BOOST_TEST(not_a_fusion_container() == v1);
BOOST_TEST(not_a_fusion_container() != 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
BOOST_TEST(not_a_fusion_container() > v1);
BOOST_TEST(not_a_fusion_container() >= v1);
BOOST_TEST(not_a_fusion_container() < v1);
BOOST_TEST(not_a_fusion_container() <= v1);
}

View File

@@ -0,0 +1,95 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005 Eric Niebler
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <string>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/list/cons.hpp>
#include <boost/fusion/container/generation/make_cons.hpp>
#include <boost/fusion/container/generation/cons_tie.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/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/algorithm/transformation/push_front.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;
namespace fusion = boost::fusion;
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((*fusion::next(begin(ns)) == hello));
*begin(ns) += 1;
*fusion::next(begin(ns)) += ' ';
BOOST_TEST((*begin(ns) == 2));
BOOST_TEST((*fusion::next(begin(ns)) == hello + ' '));
for_each(ns, boost::lambda::_1 += ' ');
BOOST_TEST((*begin(ns) == 2 + ' '));
BOOST_TEST((*fusion::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));
}
{
// This used to trigger a hard compilation error:
cons<cons<int> > xs;
begin(push_front(xs, 3));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,122 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/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;
(void)empty;
FUSION_SEQUENCE<> empty0;
(void)empty0;
#ifndef NO_CONSTRUCT_FROM_NIL
FUSION_SEQUENCE<> empty1(empty);
(void)empty1;
#endif
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
}

View File

@@ -0,0 +1,322 @@
/*=============================================================================
Copyright (c) 2016 Lee Clagett
Use modification and distribution are subject to the Boost Software
License, Version 1.0. (See accompanyintg file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
==============================================================================*/
#include <boost/config.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/boost_tuple.hpp>
#include <boost/fusion/adapted/std_pair.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) \
&& !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
# include <boost/fusion/adapted/std_tuple.hpp>
#endif
#include <boost/fusion/container/deque.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/tuple.hpp>
#include <boost/fusion/container/vector.hpp>
#include "fixture.hpp"
template <template <typename> class Scenario>
void test()
{
using namespace test_detail;
// Note the trunction conversion tests from each containter
// ... bug or feature?
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(FUSION_SEQUENCE<int>(300), 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::fusion::push_back(FUSION_SEQUENCE<int>(200), 400)
, FUSION_SEQUENCE<convertible>(200)
)
));
BOOST_TEST((run<Scenario<FUSION_SEQUENCE<> > >(boost::fusion::vector<>())));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<> > >(
boost::fusion::vector<int>(100), boost::fusion::vector<>()
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::fusion::vector<int>(110)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::fusion::vector<int, int>(200, 100)
, boost::fusion::vector<convertible>(200)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::vector<int, int>(200, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::vector<int, int, int>(500, 400, 100)
, boost::fusion::vector<convertible, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(
boost::fusion::vector<int>(500), 400
)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(
boost::fusion::vector<int, int>(500, 400), 100
)
, boost::fusion::vector<convertible, int>(500, 400)
)
));
BOOST_TEST((run<Scenario< FUSION_SEQUENCE<> > >(boost::fusion::deque<>())));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<> > >(
boost::fusion::deque<int>(100), boost::fusion::deque<>()
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::fusion::deque<int>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::fusion::deque<int, int>(500, 100)
, boost::fusion::deque<convertible>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::deque<int, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::deque<int, int, int>(500, 400, 100)
, boost::fusion::deque<convertible, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(
boost::fusion::deque<int>(500), 400
)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(
boost::fusion::deque<int, int>(500, 400), 100
)
, boost::fusion::deque<convertible, int>(500, 400)
)
));
BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(boost::fusion::list<>())));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<> > >(
boost::fusion::list<int>(100), boost::fusion::list<>()
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::fusion::list<int>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::fusion::list<int, int>(500, 100)
, boost::fusion::list<convertible>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::list<int, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::list<int, int, int>(500, 400, 100)
, boost::fusion::list<convertible, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(
boost::fusion::list<int>(500), 400
)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(
boost::fusion::list<int, int>(500, 400), 100
)
, boost::fusion::list<convertible, int>(500, 400)
)
));
BOOST_TEST((run<Scenario< FUSION_SEQUENCE<> > >(boost::fusion::tuple<>())));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<> > >(
boost::fusion::tuple<int>(100), boost::fusion::tuple<>()
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::fusion::tuple<int>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::fusion::tuple<int, int>(500, 100)
, boost::fusion::tuple<convertible>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::tuple<int, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::tuple<int, int, int>(500, 400, 100)
, boost::fusion::tuple<convertible, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(
boost::fusion::tuple<int>(500), 400
)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(
boost::fusion::tuple<int, int>(500, 400), 100
)
, boost::fusion::tuple<convertible, int>(500, 400)
)
));
BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(boost::tuple<>())));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<> > >(
boost::tuple<int>(100), boost::tuple<>()
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::tuple<int>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
boost::tuple<int, int>(500, 100)
, boost::tuple<convertible>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::tuple<int, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::tuple<int, int, int>(500, 400, 100)
, boost::tuple<convertible, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(boost::tuple<int>(500), 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(
boost::tuple<int, int>(500, 400), 100
)
, boost::tuple<convertible, int>(500, 400)
)
));
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) \
&& !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(std::tuple<>())));
BOOST_TEST((
run<Scenario<FUSION_SEQUENCE<> > >(std::tuple<int>(100), std::tuple<>())
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
std::tuple<int>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
std::tuple<int, int>(500, 100)
, std::tuple<convertible>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
std::tuple<int, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
std::tuple<int, int, int>(500, 400, 100)
, std::tuple<convertible, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(std::tuple<int>(500), 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
boost::fusion::push_back(
std::tuple<int, int>(500, 400), 100
)
, std::tuple<convertible, int>(500, 400)
)
));
#endif
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
std::pair<int, int>(500, 400)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<> > >(
std::pair<int, int>(500, 400)
, boost::fusion::vector<>()
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
std::pair<int, int>(500, 400)
, boost::fusion::vector<convertible>(500)
)
));
}

View File

@@ -0,0 +1,51 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
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 <string>
#include <boost/config.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/fusion/include/convert.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/deque.hpp>
#include <boost/fusion/include/list.hpp>
#include <boost/fusion/include/boost_tuple.hpp>
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/fusion/include/std_tuple.hpp>
#endif
template <typename Tag>
void test(FUSION_SEQUENCE<int, std::string> const& seq)
{
typedef typename
boost::fusion::result_of::convert<
Tag
, FUSION_SEQUENCE<int, std::string>
>::type
type;
type v = boost::fusion::convert<Tag>(seq);
BOOST_TEST((boost::fusion::at_c<0>(v) == 123));
BOOST_TEST((boost::fusion::at_c<1>(v) == "Hola!!!"));
}
int main()
{
FUSION_SEQUENCE<int, std::string> seq(123, "Hola!!!");
test<boost::fusion::vector_tag>(seq);
test<boost::fusion::deque_tag>(seq);
test<boost::fusion::cons_tag>(seq);
test<boost::fusion::boost_tuple_tag>(seq);
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
test<boost::fusion::std_tuple_tag>(seq);
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,14 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
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/tuple/tuple.hpp>
#include <boost/fusion/include/boost_tuple.hpp>
#define FUSION_SEQUENCE boost::tuples::tuple
#include "convert.hpp"

View File

@@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
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/include/deque.hpp>
#define FUSION_SEQUENCE boost::fusion::deque
#include "convert.hpp"

View File

@@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
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/include/list.hpp>
#define FUSION_SEQUENCE boost::fusion::list
#include "convert.hpp"

View File

@@ -0,0 +1,14 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
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 <utility>
#include <boost/fusion/include/std_pair.hpp>
#define FUSION_SEQUENCE std::pair
#include "convert.hpp"

View File

@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
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/config.hpp>
#if defined(BOOST_NO_CXX11_HDR_TUPLE) || \
defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
# error "does not meet requirements"
#endif
#include <tuple>
#include <boost/fusion/include/std_tuple.hpp>
#define FUSION_SEQUENCE std::tuple
#include "convert.hpp"

View File

@@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2015 Kohei Takahashi
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/include/vector.hpp>
#define FUSION_SEQUENCE boost::fusion::vector
#include "convert.hpp"

View File

@@ -0,0 +1,154 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <string>
#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>
#include "fixture.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(); }; };
}
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);
}
template <template <typename> class Scenario>
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]);
BOOST_TEST(FUSION_AT<0>(t1) == 4);
BOOST_TEST(FUSION_AT<1>(t1) == 'a');
// 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);
test_mpl();
BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(FUSION_SEQUENCE<>())));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<int> > >(FUSION_SEQUENCE<int>(500))
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
FUSION_SEQUENCE<int>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<int> > >(
FUSION_SEQUENCE<int, int>(500, 100)
, FUSION_SEQUENCE<int>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible> > >(
FUSION_SEQUENCE<int, int>(500, 100)
, FUSION_SEQUENCE<convertible>(500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<int, int> > >(
FUSION_SEQUENCE<int, int>(500, 600)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, int> > >(
FUSION_SEQUENCE<convertible, int>(100, 500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<int, convertible> > >(
FUSION_SEQUENCE<int, convertible>(500, 600)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, convertible> > >(
FUSION_SEQUENCE<int, int>(400, 500)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<int, int> > >(
FUSION_SEQUENCE<int, int, int>(500, 100, 323)
, FUSION_SEQUENCE<int, int>(500, 100)
)
));
BOOST_TEST((
run< Scenario< FUSION_SEQUENCE<convertible, convertible> > >(
FUSION_SEQUENCE<int, int, int>(500, 600, 100)
, FUSION_SEQUENCE<convertible, convertible>(500, 600)
)
));
}

View File

@@ -0,0 +1,91 @@
/*=============================================================================
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/config.hpp>
#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>
#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
#include <functional>
#endif
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, 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 *, 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 &);
#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
TEST_SAME_TYPE(deduce< std::reference_wrapper<int> & >::type, int &);
TEST_SAME_TYPE(deduce< std::reference_wrapper<int const> & >::type, int const &);
TEST_SAME_TYPE(deduce< std::reference_wrapper<int> const & >::type, int &);
TEST_SAME_TYPE(deduce< std::reference_wrapper<int const> const & >::type, int const &);
#endif
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();
}

View File

@@ -0,0 +1,117 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/support.hpp>
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
namespace ns
{
struct x_member;
struct y_member;
struct z_member;
}
BOOST_FUSION_DEFINE_ASSOC_STRUCT(
(ns),
point,
(int, x, ns::x_member)
(int, y, ns::y_member)
)
BOOST_FUSION_DEFINE_ASSOC_STRUCT(BOOST_PP_EMPTY(), empty_struct, )
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
BOOST_STATIC_ASSERT(!traits::is_view<ns::point>::value);
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(boost::fusion::result_of::size<ns::point>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<ns::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
}
{
vector<int, float> v1(4, 2.f);
ns::point v2(5, 3);
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);
vector<int, long> v(p);
v = p;
}
{
// conversion from ns::point to list
ns::point p(5, 3);
list<int, long> l(p);
l = p;
}
{
// assoc stuff
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<ns::point, ns::x_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<ns::point, ns::y_member>));
BOOST_MPL_ASSERT((boost::mpl::not_<boost::fusion::result_of::has_key<ns::point, ns::z_member> >));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<ns::point, ns::x_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::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);
}
{
ns::point p = make_list(5,3);
BOOST_TEST(p == make_vector(5,3));
p = make_list(3,5);
BOOST_TEST(p == make_vector(3,5));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,78 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
BOOST_FUSION_DEFINE_ASSOC_STRUCT(BOOST_PP_EMPTY(), empty_struct, )
int
main()
{
using namespace boost;
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
BOOST_STATIC_ASSERT(!traits::is_view<empty_struct>::value);
empty_struct e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct>::value);
}
{
vector<> v;
empty_struct e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(v != e);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(v > e);
BOOST_TEST(v >= e);
}
{
empty_struct e;
// conversion from empty_struct to vector
vector<> v(e);
v = e;
// conversion from empty_struct to list
//list<> l(e);
//l = e;
}
{ // begin/end
typedef fusion::result_of::begin<empty_struct>::type b;
typedef fusion::result_of::end<empty_struct>::type e;
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct, void>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct, int>));
return boost::report_errors();
}

View File

@@ -0,0 +1,67 @@
/*=============================================================================
Copyright (c) 2016,2018 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
#include <utility>
struct key_type;
struct wrapper
{
int value;
wrapper() : value(42) {}
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
wrapper(wrapper const& other) : value(other.value) {}
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
};
BOOST_FUSION_DEFINE_ASSOC_STRUCT((ns), value, (wrapper, w, key_type))
int main()
{
using namespace boost::fusion;
{
ns::value x;
ns::value y(x); // copy
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 43);
y = x; // copy assign
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
}
{
ns::value x;
ns::value y(std::move(x)); // move
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 43);
y = std::move(x); // move assign
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 0);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,121 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/support.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct x_member;
struct y_member;
struct z_member;
}
BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT(
(X)(Y),
(ns),
point,
(int, x, ns::x_member)
(int, y, ns::y_member)
)
BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT((M), BOOST_PP_EMPTY(), empty_struct, )
int
main()
{
using namespace boost::fusion;
typedef ns::point<int,int> point;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
BOOST_STATIC_ASSERT(!traits::is_view<point>::value);
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(boost::fusion::result_of::size<point>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
}
{
vector<int, float> v1(4, 2.f);
point v2(5, 3);
vector<long, double> v3(5, 4.0);
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 point to vector
point p(5, 3);
vector<int, long> v(p);
v = p;
}
{
// conversion from point to list
point p(5, 3);
list<int, long> l(p);
l = p;
}
{
// assoc stuff
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<point, ns::x_member>));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<point, ns::y_member>));
BOOST_MPL_ASSERT((boost::mpl::not_<boost::fusion::result_of::has_key<point, ns::z_member> >));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<point, ns::x_member>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_at_key<point, ns::y_member>::type, int>));
point p(5, 3);
BOOST_TEST(at_key<ns::x_member>(p) == 5);
BOOST_TEST(at_key<ns::y_member>(p) == 3);
}
{
point p = make_list(5,3);
BOOST_TEST(p == make_vector(5,3));
p = make_list(3,5);
BOOST_TEST(p == make_vector(3,5));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,78 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT((M), BOOST_PP_EMPTY(), empty_struct, )
int
main()
{
using namespace boost;
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
BOOST_STATIC_ASSERT(!traits::is_view<empty_struct<void> >::value);
empty_struct<void> e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct<void> >::value);
}
{
vector<> v;
empty_struct<void> e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(v != e);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(v > e);
BOOST_TEST(v >= e);
}
{
empty_struct<void> e;
// conversion from empty_struct to vector
vector<> v(e);
v = e;
// conversion from empty_struct to list
//list<> l(e);
//l = e;
}
{ // begin/end
typedef fusion::result_of::begin<empty_struct<void> >::type b;
typedef fusion::result_of::end<empty_struct<void> >::type e;
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct<void>, void>));
BOOST_MPL_ASSERT_NOT((fusion::result_of::has_key<empty_struct<void>, int>));
return boost::report_errors();
}

View File

@@ -0,0 +1,78 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/config.hpp>
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
#include <utility>
struct key_type;
struct wrapper
{
int value;
wrapper() : value(42) {}
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
wrapper(wrapper const& other) : value(other.value) {}
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
};
BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT((W), (ns), value, (W, w, key_type))
int main()
{
using namespace boost::fusion;
{
ns::value<wrapper> x;
ns::value<wrapper> y(x); // copy
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 43);
y = x; // copy assign
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
}
{
ns::value<wrapper> x;
ns::value<wrapper> y(std::move(x)); // move
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 43);
y = std::move(x); // move assign
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 0);
}
return boost::report_errors();
}
#else
int main()
{
}
#endif

View File

@@ -0,0 +1,130 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/support.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
BOOST_FUSION_DEFINE_STRUCT(
(ns),
point,
(int, x)
(int, y)
)
// Tutorial (compile test only)
BOOST_FUSION_DEFINE_STRUCT(
(demo), employee,
(std::string, name)
(int, age)
)
BOOST_FUSION_DEFINE_STRUCT(BOOST_PP_EMPTY(), s, (int, m))
BOOST_FUSION_DEFINE_STRUCT(BOOST_PP_EMPTY(), empty_struct, )
// Testing non-constexpr compatible types
BOOST_FUSION_DEFINE_STRUCT(
(ns),
employee,
(std::string, name)
(std::string, nickname)
)
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
BOOST_STATIC_ASSERT(!traits::is_view<ns::point>::value);
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(boost::fusion::result_of::size<ns::point>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<ns::point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
}
{
vector<int, float> v1(4, 2.f);
ns::point v2(5, 3);
vector<long, double> v3(5, 4.0);
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);
vector<int, long> v(p);
v = p;
}
{
// conversion from ns::point to list
ns::point p(5, 3);
list<int, long> l(p);
l = p;
}
{ // begin/end
using namespace boost::fusion;
typedef boost::fusion::result_of::begin<s>::type b;
typedef boost::fusion::result_of::end<s>::type e;
// this fails
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::next<b>::type, e>));
}
{
ns::point p = make_list(5,3);
BOOST_TEST(p == make_vector(5,3));
p = make_list(3,5);
BOOST_TEST(p == make_vector(3,5));
}
{
ns::employee emp = make_list("John Doe", "jdoe");
std::cout << at_c<0>(emp) << std::endl;
std::cout << at_c<1>(emp) << std::endl;
BOOST_TEST(emp == make_vector("John Doe", "jdoe"));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,76 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
BOOST_FUSION_DEFINE_STRUCT(BOOST_PP_EMPTY(), empty_struct, )
int
main()
{
using namespace boost;
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
BOOST_STATIC_ASSERT(!traits::is_view<empty_struct>::value);
empty_struct e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct>::value);
}
{
vector<> v;
empty_struct e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(v != e);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(v > e);
BOOST_TEST(v >= e);
}
{
empty_struct e;
// conversion from empty_struct to vector
vector<> v(e);
v = e;
// conversion from empty_struct to list
//list<> l(e);
//l = e;
}
{ // begin/end
typedef fusion::result_of::begin<empty_struct>::type b;
typedef fusion::result_of::end<empty_struct>::type e;
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>));
return boost::report_errors();
}

View File

@@ -0,0 +1,153 @@
/*=============================================================================
Copyright (c) 2010, 2012 Christopher Schmidt, Nathan Ridge
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.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/support.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
struct cls
{
BOOST_FUSION_DEFINE_STRUCT_INLINE(
point,
(int, x)
(int, y)
)
};
template <typename = int>
struct tpl_cls
{
BOOST_FUSION_DEFINE_STRUCT_INLINE(
point,
(int, x)
(int, y)
)
};
namespace ns
{
BOOST_FUSION_DEFINE_STRUCT_INLINE(s, (int, m))
BOOST_FUSION_DEFINE_STRUCT_INLINE(empty_struct, )
// Testing non-constexpr compatible types
BOOST_FUSION_DEFINE_STRUCT_INLINE(
employee,
(std::string, name)
(std::string, nickname)
)
}
template <typename Point>
void run_test()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<ns::empty_struct>::value == 0);
BOOST_STATIC_ASSERT(boost::fusion::result_of::empty<ns::empty_struct>::value);
}
{
BOOST_MPL_ASSERT_NOT((traits::is_view<Point>));
BOOST_STATIC_ASSERT(!traits::is_view<Point>::value);
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(boost::fusion::result_of::size<Point>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<Point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
}
{
vector<int, float> v1(4, 2.0f);
Point v2(5, 3);
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 Point to vector
Point p(5, 3);
vector<int, long> v(p);
v = p;
}
{
// conversion from Point to list
Point p(5, 3);
list<int, long> l(p);
l = p;
}
{ // begin/end
using namespace boost::fusion;
typedef boost::fusion::result_of::begin<ns::s>::type b;
typedef boost::fusion::result_of::end<ns::s>::type e;
// this fails
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::next<b>::type, e>));
}
{
Point p = make_list(5,3);
BOOST_TEST(p == make_vector(5,3));
p = make_list(3,5);
BOOST_TEST(p == make_vector(3,5));
}
}
int
main()
{
run_test<cls::point>(); // test with non-template enclosing class
run_test<tpl_cls<>::point>(); // test with template enclosing class
{
using namespace boost::fusion;
ns::employee emp = make_list("John Doe", "jdoe");
std::cout << at_c<0>(emp) << std::endl;
std::cout << at_c<1>(emp) << std::endl;
BOOST_TEST(emp == make_vector("John Doe", "jdoe"));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,76 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
BOOST_FUSION_DEFINE_STRUCT_INLINE(empty_struct, )
int
main()
{
using namespace boost;
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct>));
BOOST_STATIC_ASSERT(!traits::is_view<empty_struct>::value);
empty_struct e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct>::value == 0);
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct>::value);
}
{
vector<> v;
empty_struct e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(v != e);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(v > e);
BOOST_TEST(v >= e);
}
{
empty_struct e;
// conversion from empty_struct to vector
vector<> v(e);
v = e;
// conversion from empty_struct to list
//list<> l(e);
//l = e;
}
{ // begin/end
typedef fusion::result_of::begin<empty_struct>::type b;
typedef fusion::result_of::end<empty_struct>::type e;
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct>));
return boost::report_errors();
}

View File

@@ -0,0 +1,73 @@
/*=============================================================================
Copyright (c) 2016-2018 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
#include <utility>
struct wrapper
{
int value;
wrapper() : value(42) {}
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
wrapper(wrapper const& other) : value(other.value) {}
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
};
namespace ns
{
BOOST_FUSION_DEFINE_STRUCT_INLINE(value, (wrapper, w))
}
int main()
{
using namespace boost::fusion;
{
ns::value x;
ns::value y(x); // copy
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 43);
y = x; // copy assign
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
}
// Older MSVCs and gcc 4.4 don't generate move ctor by default.
#if !(defined(CI_SKIP_KNOWN_FAILURE) && (BOOST_WORKAROUND(BOOST_MSVC, < 1900) || BOOST_WORKAROUND(BOOST_GCC, / 100 == 404)))
{
ns::value x;
ns::value y(std::move(x)); // move
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 43);
y = std::move(x); // move assign
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 0);
}
#endif // !(ci && (msvc < 14.0 || gcc 4.4.x))
return boost::report_errors();
}

View File

@@ -0,0 +1,66 @@
/*=============================================================================
Copyright (c) 2016,2018 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <utility>
struct wrapper
{
int value;
wrapper() : value(42) {}
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
wrapper(wrapper const& other) : value(other.value) {}
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
};
BOOST_FUSION_DEFINE_STRUCT((ns), value, (wrapper, w))
int main()
{
using namespace boost::fusion;
{
ns::value x;
ns::value y(x); // copy
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 43);
y = x; // copy assign
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
}
{
ns::value x;
ns::value y(std::move(x)); // move
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 43);
y = std::move(x); // move assign
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 0);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,112 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/support.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
BOOST_FUSION_DEFINE_TPL_STRUCT(
(X)(Y),
(ns),
point,
(X, x)
(Y, y)
)
BOOST_FUSION_DEFINE_TPL_STRUCT((M), BOOST_PP_EMPTY(), s, (M, m))
BOOST_FUSION_DEFINE_TPL_STRUCT((M), BOOST_PP_EMPTY(), empty_struct, )
int
main()
{
using namespace boost::fusion;
typedef ns::point<int, int> point;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
BOOST_STATIC_ASSERT(!traits::is_view<point>::value);
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(boost::fusion::result_of::size<point>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
}
{
vector<int, float> v1(4, 2.f);
point v2(5, 3);
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 point to vector
point p(5, 3);
vector<int, long> v(p);
v = p;
}
{
// conversion from point to list
point p(5, 3);
list<int, long> l(p);
l = p;
}
{ // begin/end
using namespace boost::fusion;
typedef boost::fusion::result_of::begin<s<int> >::type b;
typedef boost::fusion::result_of::end<s<int> >::type e;
// this fails
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::next<b>::type, e>));
}
{
point p = make_list(5,3);
BOOST_TEST(p == make_vector(5,3));
p = make_list(3,5);
BOOST_TEST(p == make_vector(3,5));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,75 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
BOOST_FUSION_DEFINE_TPL_STRUCT((M), BOOST_PP_EMPTY(), empty_struct, )
int
main()
{
using namespace boost;
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
empty_struct<void> e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct<void> >::value);
}
{
vector<> v;
empty_struct<void> e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(v != e);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(v > e);
BOOST_TEST(v >= e);
}
{
empty_struct<void> e;
// conversion from empty_struct to vector
vector<> v(e);
v = e;
// conversion from empty_struct to list
//list<> l(e);
//l = e;
}
{ // begin/end
typedef fusion::result_of::begin<empty_struct<void> >::type b;
typedef fusion::result_of::end<empty_struct<void> >::type e;
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
return boost::report_errors();
}

View File

@@ -0,0 +1,138 @@
/*=============================================================================
Copyright (c) 2010, 2012 Christopher Schmidt, nathan Ridge
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.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/support.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <string>
struct cls
{
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
(X)(Y),
point,
(X, x)
(Y, y)
)
};
template <typename = int>
struct tpl_cls
{
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
(X)(Y),
point,
(X, x)
(Y, y)
)
};
namespace ns
{
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M), s, (M, m))
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M), empty_struct, )
}
template <typename Point>
void run_test()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<ns::empty_struct<int> >::value == 0);
BOOST_STATIC_ASSERT(boost::fusion::result_of::empty<ns::empty_struct<int> >::value);
}
{
BOOST_MPL_ASSERT_NOT((traits::is_view<Point>));
BOOST_STATIC_ASSERT(!traits::is_view<Point>::value);
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(boost::fusion::result_of::size<Point>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<Point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
}
{
vector<int, float> v1(4, 2.f);
Point v2(5, 3);
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 Point to vector
Point p(5, 3);
vector<int, long> v(p);
v = p;
}
{
// conversion from Point to list
Point p(5, 3);
list<int, long> l(p);
l = p;
}
{ // begin/end
using namespace boost::fusion;
typedef boost::fusion::result_of::begin<ns::s<int> >::type b;
typedef boost::fusion::result_of::end<ns::s<int> >::type e;
// this fails
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::next<b>::type, e>));
}
{
Point p = make_list(5,3);
BOOST_TEST(p == make_vector(5,3));
p = make_list(3,5);
BOOST_TEST(p == make_vector(3,5));
}
}
int
main()
{
run_test<cls::point<int, int> >(); // test non-template enclosing class
run_test<tpl_cls<>::point<int, int> >(); // test template enclosing class
return boost::report_errors();
}

View File

@@ -0,0 +1,75 @@
/*=============================================================================
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M), empty_struct, )
int
main()
{
using namespace boost;
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
BOOST_MPL_ASSERT_NOT((traits::is_view<empty_struct<void> >));
empty_struct<void> e;
std::cout << e << std::endl;
BOOST_TEST(e == make_vector());
BOOST_STATIC_ASSERT(fusion::result_of::size<empty_struct<void> >::value == 0);
BOOST_STATIC_ASSERT(fusion::result_of::empty<empty_struct<void> >::value);
}
{
vector<> v;
empty_struct<void> e;
BOOST_TEST(v == e);
BOOST_TEST_NOT(v != e);
BOOST_TEST_NOT(v < e);
BOOST_TEST(v <= e);
BOOST_TEST_NOT(v > e);
BOOST_TEST(v >= e);
}
{
empty_struct<void> e;
// conversion from empty_struct to vector
vector<> v(e);
v = e;
// conversion from empty_struct to list
//list<> l(e);
//l = e;
}
{ // begin/end
typedef fusion::result_of::begin<empty_struct<void> >::type b;
typedef fusion::result_of::end<empty_struct<void> >::type e;
BOOST_MPL_ASSERT((fusion::result_of::equal_to<b, e>));
}
BOOST_MPL_ASSERT((mpl::is_sequence<empty_struct<void> >));
return boost::report_errors();
}

View File

@@ -0,0 +1,73 @@
/*=============================================================================
Copyright (c) 2016-2018 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/define_struct_inline.hpp>
#include <utility>
struct wrapper
{
int value;
wrapper() : value(42) {}
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
wrapper(wrapper const& other) : value(other.value) {}
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
};
namespace ns
{
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((W), value, (W, w))
}
int main()
{
using namespace boost::fusion;
{
ns::value<wrapper> x;
ns::value<wrapper> y(x); // copy
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 43);
y = x; // copy assign
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
}
// Older MSVCs and gcc 4.4 don't generate move ctor by default.
#if !(defined(CI_SKIP_KNOWN_FAILURE) && (BOOST_WORKAROUND(BOOST_MSVC, < 1900) || BOOST_WORKAROUND(BOOST_GCC, / 100 == 404)))
{
ns::value<wrapper> x;
ns::value<wrapper> y(std::move(x)); // move
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 43);
y = std::move(x); // move assign
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 0);
}
#endif // !(ci && (msvc < 14.0 || gcc 4.4.x))
return boost::report_errors();
}

View File

@@ -0,0 +1,66 @@
/*=============================================================================
Copyright (c) 2016,2018 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <utility>
struct wrapper
{
int value;
wrapper() : value(42) {}
wrapper(wrapper&& other) : value(other.value) { other.value = 0; }
wrapper(wrapper const& other) : value(other.value) {}
wrapper& operator=(wrapper&& other) { value = other.value; other.value = 0; return *this; }
wrapper& operator=(wrapper const& other) { value = other.value; return *this; }
};
BOOST_FUSION_DEFINE_TPL_STRUCT((W), (ns), value, (W, w))
int main()
{
using namespace boost::fusion;
{
ns::value<wrapper> x;
ns::value<wrapper> y(x); // copy
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 43);
y = x; // copy assign
BOOST_TEST(x.w.value == 42);
BOOST_TEST(y.w.value == 42);
}
{
ns::value<wrapper> x;
ns::value<wrapper> y(std::move(x)); // move
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 42);
++y.w.value;
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 43);
y = std::move(x); // move assign
BOOST_TEST(x.w.value == 0);
BOOST_TEST(y.w.value == 0);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/deque/deque.hpp>
#define FUSION_SEQUENCE deque
#include "comparison.hpp"
int
main()
{
equality_test();
ordering_test();
return boost::report_errors();
}

View File

@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/deque/deque.hpp>
#define FUSION_SEQUENCE deque
#include "construction.hpp"
int
main()
{
test();
return boost::report_errors();
}

View File

@@ -0,0 +1,42 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/deque/deque.hpp>
#include <boost/fusion/container/generation/make_deque.hpp>
#include <boost/fusion/container/generation/deque_tie.hpp>
#define FUSION_SEQUENCE deque
#include "copy.hpp"
using namespace test_detail;
// c++11 deque has bug, cannot properly copy-assign from a const value
template <typename T>
struct skip_const_lvalue_assignment
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
return
run< can_implicit_construct<T> >(source, expected) &&
run< can_construct<T> >(source, expected) &&
run< can_rvalue_assign<T> >(source, expected) &&
run< can_lvalue_assign<T> >(source, expected);
}
};
int
main()
{
#if defined(BOOST_FUSION_HAS_VARIADIC_DEQUE)
test<skip_const_lvalue_assignment>();
#else
test<can_copy>();
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,16 @@
/*=============================================================================
Copyright (c) 2014 Christoph Weiss
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 "hash.hpp"
int main()
{
hash_test();
return boost::report_errors();
}

View File

@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 2015 Louis Dionne
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/config.hpp>
#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS
#include <type_traits>
#include <boost/fusion/include/deque.hpp>
struct Dummy { };
// Make sure deque's constructor is SFINAE-friendly.
static_assert(!std::is_constructible<boost::fusion::deque<int>, Dummy const&>::value, "");
#endif

View File

@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/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();
}

View File

@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/deque/deque.hpp>
#include <boost/fusion/container/generation/make_deque.hpp>
#define FUSION_SEQUENCE deque
#include "make.hpp"
int
main()
{
test();
return boost::report_errors();
}

View File

@@ -0,0 +1,24 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/deque/deque.hpp>
#include <boost/fusion/container/deque/convert.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#define BOOST_FUSION_SEQUENCE_CONVERSION_IS_NOT_SEQUENCE__TYPE_PRESERVING
#define FUSION_SEQUENCE deque
#include "misc.hpp"
int
main()
{
test();
return boost::report_errors();
}

View File

@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 2012 Joel de Guzman
Copyright (c) 2018 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#define BOOST_FUSION_DONT_USE_PREPROCESSED_FILES
#include <boost/fusion/container/deque/deque.hpp>
#define FUSION_SEQUENCE boost::fusion::deque<std::vector<x>>
#define FUSION_SEQUENCE2 boost::fusion::deque<std::vector<x>, x>
#include "move.hpp"
int main()
{
test();
return boost::report_errors();
}

View File

@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/deque/deque.hpp>
#define FUSION_SEQUENCE deque
#include "mutate.hpp"
int
main()
{
test();
return boost::report_errors();
}

View File

@@ -0,0 +1,43 @@
/*=============================================================================
Copyright (C) 2015 Kohei Takahshi
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/core/lightweight_test.hpp>
#define FUSION_SEQUENCE boost::fusion::deque
#include "nest.hpp"
/* deque has a few issues:
- sequence conversion constructor is explicit
- assignment sequence conversion has bug in base class
- c++11 direct assignment from lvalue has bug */
template <typename T>
struct skip_issues
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
using namespace test_detail;
return
#if defined(BOOST_FUSION_HAS_VARIADIC_DEQUE)
run< can_construct<T> >(source, expected) &&
run< can_implicit_construct<T> >(source, expected) &&
run< can_rvalue_assign<T> >(source, expected) &&
run< can_convert_using<can_construct>::to<T> >(source, expected) &&
#else
run< can_copy<T> >(source, expected) &&
#endif
run< can_construct_from_elements<T> >(source, expected);
}
};
int
main()
{
test<skip_issues>();
return boost::report_errors();
}

View File

@@ -0,0 +1,23 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/deque/deque.hpp>
#include <boost/fusion/container/generation/deque_tie.hpp>
#include <boost/fusion/container/generation/ignore.hpp>
#include <boost/fusion/container/generation/make_deque.hpp>
#define FUSION_SEQUENCE deque
#include "tie.hpp"
int
main()
{
test();
return boost::report_errors();
}

View File

@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/deque/deque.hpp>
#define FUSION_SEQUENCE deque
#include "value_at.hpp"
int
main()
{
test();
return boost::report_errors();
}

View File

@@ -0,0 +1,129 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/container/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/container/generation/make_vector.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/container/map.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/value_of_data.hpp>
#include <boost/fusion/iterator/deref_data.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(", ");
{
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(boost::fusion::result_of::size<filter_view_type>::value == 4);
}
//cschmidt: This is illegal C++. ADL instantiates less<_, int_<3> > - which
//leads to compile errors.
/*{
// $$$ 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.
#ifndef __EDG_VERSION__
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(boost::fusion::result_of::size<filter_view_type>::value == 4);
#endif
}*/
{
// 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((boost::fusion::result_of::equal_to<boost::fusion::result_of::begin<filter_view_type>::type, boost::fusion::result_of::end<filter_view_type>::type>));
}
{
typedef map<pair<void, int>, pair<double, std::string> > map_type;
map_type m(make_pair<void>(0), make_pair<double>("Bond"));
typedef filter_view<map_type const, is_same<_, pair<double, std::string> > > filter_view_type;
filter_view_type f(m);
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<filter_view_type, double>::type));
BOOST_MPL_ASSERT_NOT((boost::fusion::result_of::has_key<filter_view_type, void>::type));
BOOST_MPL_ASSERT((is_same<boost::fusion::result_of::key_of<boost::fusion::result_of::begin<filter_view_type>::type>::type, double>));
BOOST_MPL_ASSERT((is_same<boost::fusion::result_of::value_of_data<boost::fusion::result_of::begin<filter_view_type>::type>::type, std::string>));
std::cout << deref_data(begin(f)) << std::endl;
BOOST_TEST((deref_data(begin(f)) == "Bond"));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,216 @@
/*=============================================================================
Copyright (c) 2016 Lee Clagett
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/comparison.hpp>
#include <boost/mpl/identity.hpp>
namespace test_detail
{
struct convertible
{
convertible() : value_() {}
convertible(int value) : value_(value) {}
int value_;
};
bool operator==(convertible const& lhs, convertible const& rhs)
{
return lhs.value_ == rhs.value_;
}
bool operator!=(convertible const& lhs, convertible const& rhs)
{
return lhs.value_ != rhs.value_;
}
// Testing conversion at function call allows for testing mutable lvalue,
// const lvalue, and rvalue as the source. mpl::identity prevents deduction
template <typename T>
T implicit_construct(typename boost::mpl::identity<T>::type source)
{
return source;
}
template <typename F, typename Source, typename Expected>
bool run(Source const& source, Expected const& expected)
{
return F()(source, expected);
}
template <typename F, typename Source>
bool run(Source const& source)
{
return run<F>(source, source);
}
template <typename T>
struct can_rvalue_implicit_construct
{
template<typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
return expected == implicit_construct<T>(implicit_construct<Source>(source));
}
};
template <typename T>
struct can_lvalue_implicit_construct
{
template <typename Source, typename Expected>
bool operator()(Source source, Expected const& expected) const
{
return expected == implicit_construct<T>(source);
}
};
template <typename T>
struct can_const_lvalue_implicit_construct
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
return expected == implicit_construct<T>(source);
}
};
template <typename T>
struct can_implicit_construct
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
return
run< can_rvalue_implicit_construct<T> >(source, expected) &&
run< can_lvalue_implicit_construct<T> >(source, expected) &&
run< can_const_lvalue_implicit_construct<T> >(source, expected);
}
};
template <typename T>
struct can_rvalue_construct
{
template<typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
return expected == T(implicit_construct<Source>(source));
}
};
template <typename T>
struct can_lvalue_construct
{
template <typename Source, typename Expected>
bool operator()(Source source, Expected const& expected) const
{
return expected == T(source);
}
};
template <typename T>
struct can_const_lvalue_construct
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
return expected == T(source);
}
};
template <typename T>
struct can_construct
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
return
run< can_rvalue_construct<T> >(source, expected) &&
run< can_lvalue_construct<T> >(source, expected) &&
run< can_const_lvalue_construct<T> >(source, expected);
}
};
template <typename T>
struct can_rvalue_assign
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
bool result = true;
{
T seq;
result &= (seq == expected || seq != expected);
seq = implicit_construct<Source>(source);
result &= (seq == expected);
}
return result;
}
};
template <typename T>
struct can_lvalue_assign
{
template <typename Source, typename Expected>
bool operator()(Source source, Expected const& expected) const
{
bool result = true;
{
T seq;
result &= (seq == expected || seq != expected);
seq = source;
result &= (seq == expected);
}
return result;
}
};
template <typename T>
struct can_const_lvalue_assign
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
bool result = true;
{
T seq;
result &= (seq == expected || seq != expected);
seq = source;
result &= (seq == expected);
}
return result;
}
};
template <typename T>
struct can_assign
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
return
run< can_rvalue_assign<T> >(source, expected) &&
run< can_lvalue_assign<T> >(source, expected) &&
run< can_const_lvalue_assign<T> >(source, expected);
}
};
template <typename T>
struct can_copy
{
template <typename Source, typename Expected>
bool operator()(Source const& source, Expected const& expected) const
{
return
run< can_construct<T> >(source, expected) &&
run< can_implicit_construct<T> >(source, expected) &&
run< can_assign<T> >(source, expected);
}
};
} // test_detail

View File

@@ -0,0 +1,56 @@
/*==============================================================================
Copyright (c) 2013 Jamboree
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/view/flatten_view/flatten_view.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/distance.hpp>
#include <boost/fusion/algorithm/auxiliary/copy.hpp>
int main()
{
using namespace boost::fusion;
{
typedef vector<int, int, vector<int, int>, int> sequence_type;
sequence_type seq(1, 2, make_vector(3, 4), 5);
flatten_view<sequence_type> flattened(seq);
BOOST_TEST((boost::fusion::size(flattened) == 5));
BOOST_TEST((boost::fusion::distance(boost::fusion::begin(flattened), boost::fusion::end(flattened)) == 5));
}
{
typedef vector<int, int, vector<int, int>, int> sequence_type;
sequence_type seq(1, 2, make_vector(3, 4), 5);
flatten_view<sequence_type> flattened(seq);
std::cout << flattened << std::endl;
BOOST_TEST((flattened == make_vector(1, 2, 3, 4, 5)));
BOOST_TEST((*advance_c<2>(boost::fusion::begin(flattened)) == 3));
}
{
typedef vector<int, int, vector<int, int>, int> sequence_type;
sequence_type seq;
flatten_view<sequence_type> flattened(seq);
copy(make_vector(1, 2, 3, 4, 5), flattened);
std::cout << seq << std::endl;
BOOST_TEST((seq == make_vector(1, 2, make_vector(3, 4), 5)));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,114 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/deque/deque.hpp>
#include <boost/fusion/container/deque/front_extended_deque.hpp>
#include <boost/fusion/sequence/comparison.hpp>
#include <boost/fusion/container/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<> initial_deque_type;
initial_deque_type initial_deque;
typedef front_extended_deque<initial_deque_type, int> extended_type;
extended_type extended(initial_deque, 1);
BOOST_TEST(size(extended) == 1);
BOOST_TEST(extended == make_vector(1));
BOOST_TEST(*begin(extended) == 1);
BOOST_TEST(*prior(end(extended)) == 1);
BOOST_TEST(distance(begin(extended), end(extended)) == 1);
}
{
namespace mpl = boost::mpl;
typedef deque<> 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::deref<mpl::begin<extended_type>::type>::type, int>));
BOOST_MPL_ASSERT((mpl::equal_to<mpl::size<extended_type>::type, mpl::int_<1> >));
}
{
int i(1);
typedef deque<> initial_deque_type;
initial_deque_type initial_deque;
typedef front_extended_deque<initial_deque_type, int&> extended_type;
extended_type extended(initial_deque, i);
BOOST_TEST(extended == make_vector(1));
int i2(2);
extended_type extended2(initial_deque_type(), i2);
extended = extended2;
BOOST_TEST(extended == make_vector(2));
BOOST_TEST(i == i2);
}
{
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();
}

View File

@@ -0,0 +1,16 @@
/*=============================================================================
Copyright (c) 2017 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/type.hpp>
int main()
{
boost::fusion::vector<int, float> v1;
boost::fusion::vector<int, float> v2(v1);
v1 = v2;
}

View File

@@ -0,0 +1,90 @@
/*=============================================================================
Copyright (c) 2018 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/container/deque.hpp>
#include <boost/fusion/container/map.hpp>
#include <boost/fusion/container/set.hpp>
#include <boost/fusion/tuple/tuple.hpp>
#include <boost/core/lightweight_test.hpp>
template <typename Sequence>
void test_at()
{
Sequence seq;
// zero initialized
BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 0);
BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 0);
BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 0);
int (&arr)[3] = boost::fusion::deref(boost::fusion::begin(seq));
arr[0] = 2;
arr[1] = 4;
arr[2] = 6;
BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 2);
BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 4);
BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 6);
boost::fusion::at_c<0>(seq)[1] = 42;
BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 2);
BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 42);
BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 6);
}
template <typename T> inline T& value(T& v) { return v; }
template <typename K, typename T> inline T& value(boost::fusion::pair<K, T>& v) { return v.second; }
template <typename Sequence>
void test_at_key()
{
Sequence seq;
// zero initialized
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[0] == 0);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[1] == 0);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[2] == 0);
int (&arr)[3] = value(boost::fusion::deref(boost::fusion::begin(seq)));
arr[0] = 2;
arr[1] = 4;
arr[2] = 6;
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[0] == 2);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[1] == 4);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[2] == 6);
boost::fusion::at_key<int[3]>(seq)[1] = 42;
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[0] == 2);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[1] == 42);
BOOST_TEST(boost::fusion::at_key<int[3]>(seq)[2] == 6);
}
int main()
{
using namespace boost::fusion;
test_at<vector<int[3]> >();
test_at<deque<int[3]> >();
test_at<list<int[3]> >();
test_at<tuple<int[3]> >();
#if !BOOST_WORKAROUND(BOOST_GCC, / 100 == 406) || defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
// FIXME: gcc 4.6 w/ c++0x doesn't like set with array...
test_at_key<set<int[3]> >();
#endif
test_at_key<map<pair<int[3], int[3]> > >();
return boost::report_errors();
}

View File

@@ -0,0 +1,59 @@
/*=============================================================================
Copyright (c) 2014 Christoph Weiss
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/core/lightweight_test.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/sequence/hash.hpp>
struct test_struct
{
test_struct(bool bb, int ii, char cc, std::string const& ss) :
b(bb),
i(ii),
c(cc),
s(ss) {}
bool b;
int i;
char c;
std::string s;
};
BOOST_FUSION_ADAPT_STRUCT(
test_struct,
(bool, b)
(int, i)
(char, c)
(std::string, s)
)
int main()
{
using boost::fusion::hash_value;
const test_struct a0(false, 1, 'c', "Hello Nurse"),
a1(false, 1, 'c', "Hello Nurse"),
b(true, 1, 'c', "Hello Nurse"),
c(false, 0, 'c', "Hello Nurse"),
d(false, 1, 'd', "Hello Nurse"),
e(false, 1, 'c', "Hello World");
BOOST_TEST(hash_value(a0) == hash_value(a1));
BOOST_TEST(hash_value(a0) != hash_value(b));
BOOST_TEST(hash_value(a0) != hash_value(c));
BOOST_TEST(hash_value(a0) != hash_value(d));
BOOST_TEST(hash_value(a0) != hash_value(e));
BOOST_TEST(hash_value(b) != hash_value(c));
BOOST_TEST(hash_value(b) != hash_value(d));
BOOST_TEST(hash_value(b) != hash_value(d));
BOOST_TEST(hash_value(c) != hash_value(d));
BOOST_TEST(hash_value(c) != hash_value(e));
BOOST_TEST(hash_value(d) != hash_value(e));
return boost::report_errors();
}

View File

@@ -0,0 +1,35 @@
/*=============================================================================
Copyright (c) 2014 Christoph Weiss
Copyright (c) 2017 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <string>
#include <utility>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence/hash.hpp>
#include <boost/functional/hash.hpp>
void hash_test()
{
namespace fusion = boost::fusion;
using namespace fusion;
const FUSION_SEQUENCE<int, char, bool, std::string> v0(42, 'x', false, "Aurea prima");
const FUSION_SEQUENCE<int, char, bool, std::string> v1(42, 'x', false, "Aurea prima");
BOOST_TEST(fusion::hash_value(v0) == fusion::hash_value(v1));
const FUSION_SEQUENCE<int, char, bool, std::string> w(41, 'x', false, "Aurea prima");
BOOST_TEST(fusion::hash_value(w) != fusion::hash_value(v0));
const FUSION_SEQUENCE<int, char, bool, std::string> x(42, 'y', false, "Aurea prima");
BOOST_TEST(fusion::hash_value(x) != fusion::hash_value(v0));
const FUSION_SEQUENCE<int, char, bool, std::string> y(42, 'x', true, "Aurea prima");
BOOST_TEST(fusion::hash_value(y) != fusion::hash_value(v0));
const FUSION_SEQUENCE<int, char, bool, std::string> z(42, 'x', false, "quae vindice nullo");
BOOST_TEST(fusion::hash_value(z) != fusion::hash_value(v0));
}

View File

@@ -0,0 +1,131 @@
/*=============================================================================
Copyright (C) 1999-2003 Jaakko Jarvi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/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)") );
}
{
useThisOStringStream os2;
// Set format (a:b:c) for os2;
os2 << tuple_open('(');
os2 << tuple_close(')');
os2 << tuple_delimiter(':');
// overwrite previous setting
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(!!(is >> ti));
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();
}

View File

@@ -0,0 +1,200 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <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 boost::fusion::next;
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);
boost::fusion::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);
boost::fusion::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 boost::fusion::result_of::begin<seq_type>::type vi1;
typedef boost::fusion::result_of::begin<cseq_type>::type vi2;
BOOST_STATIC_ASSERT((boost::fusion::result_of::equal_to<vi1 const, vi1>::value));
BOOST_STATIC_ASSERT((boost::fusion::result_of::equal_to<vi1, vi1 const>::value));
BOOST_STATIC_ASSERT((boost::fusion::result_of::equal_to<vi1, vi2>::value));
BOOST_STATIC_ASSERT((boost::fusion::result_of::equal_to<vi1 const, vi2>::value));
BOOST_STATIC_ASSERT((boost::fusion::result_of::equal_to<vi1, vi2 const>::value));
BOOST_STATIC_ASSERT((boost::fusion::result_of::equal_to<vi1 const, vi2 const>::value));
}
{
typedef FUSION_SEQUENCE<int, int> seq_type;
typedef boost::fusion::result_of::begin<seq_type>::type begin_type;
typedef boost::fusion::result_of::end<seq_type>::type end_type;
typedef boost::fusion::result_of::next<begin_type>::type i1;
typedef boost::fusion::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);
boost::fusion::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((boost::fusion::result_of::distance<
boost::fusion::result_of::begin<seq_type>::type
, boost::fusion::result_of::end<seq_type>::type >::value == 4));
BOOST_TEST(distance(begin(t), end(t)).value == 4);
}
{ // Testing tuple iterator boost::fusion::result_of::value_of, boost::fusion::result_of::deref, boost::fusion::result_of::value_at
typedef FUSION_SEQUENCE<int, char&> seq_type;
typedef boost::fusion::result_of::begin<seq_type>::type i0;
typedef boost::fusion::result_of::next<i0>::type i1;
typedef boost::fusion::result_of::next<boost::fusion::result_of::begin<const seq_type>::type>::type i2;
BOOST_STATIC_ASSERT((
is_same<boost::fusion::result_of::value_at_c<seq_type, 0>::type, int>::value));
BOOST_STATIC_ASSERT((
is_same<boost::fusion::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<boost::fusion::result_of::deref<i0>::type, int&>::value));
BOOST_STATIC_ASSERT((is_same<boost::fusion::result_of::deref<i1>::type, char&>::value));
BOOST_STATIC_ASSERT((is_same<boost::fusion::result_of::deref<i2>::type, char&>::value));
BOOST_STATIC_ASSERT((is_same<boost::fusion::result_of::value_of<i0>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<boost::fusion::result_of::value_of<i1>::type, char&>::value));
BOOST_STATIC_ASSERT((is_same<boost::fusion::result_of::value_of<i2>::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));
}
}

View File

@@ -0,0 +1,115 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/map.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/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/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/value_of_data.hpp>
#include <boost/fusion/iterator/deref_data.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/begin.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
int
main()
{
using namespace boost::fusion;
namespace fusion = 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(boost::fusion::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(boost::fusion::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(boost::fusion::result_of::size<slice_t>::value == 2);
}
{
typedef map<pair<void,std::string>, pair<double,char>,pair<void*, int> > map_type;
map_type m(make_pair<void>("foo"), make_pair<double>('x'), make_pair<void*>(2));
typedef iterator_range<
boost::fusion::result_of::begin<map_type>::type
, boost::fusion::result_of::advance_c<boost::fusion::result_of::begin<map_type>::type,2>::type
> range_type;
range_type r(begin(m), advance_c<2>(begin(m)));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<range_type, void>::type));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<range_type, double>::type));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::key_of<boost::fusion::result_of::begin<range_type>::type>::type, void>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::key_of<boost::fusion::result_of::next<boost::fusion::result_of::begin<range_type>::type>::type>::type, double>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_of_data<boost::fusion::result_of::begin<range_type>::type>::type, std::string>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_of_data<boost::fusion::result_of::next<boost::fusion::result_of::begin<range_type>::type>::type>::type, char>));
std::cout << deref_data(begin(r)) << std::endl;
std::cout << deref_data(fusion::next(begin(r))) << std::endl;
BOOST_TEST((deref_data(begin(r)) == "foo"));
BOOST_TEST((deref_data(fusion::next(begin(r))) == 'x'));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,188 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/map.hpp>
#include <boost/fusion/container/set.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/container/generation/make_vector.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/iterator/deref_data.hpp>
#include <boost/mpl/assert.hpp>
#include <string>
struct X
{
operator char const*() const
{
return "<X-object>";
}
};
int
main()
{
using namespace boost::fusion;
namespace fusion = 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());
}
}
{
typedef map<pair<void,int> > map_type;
map_type m(make_pair<void>(0));
typedef set<std::string, float> set_type;
set_type s("foo", 1.3f);
typedef joint_view<map_type, set_type> joint_view_type;
joint_view_type j(m,s);
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<joint_view_type, void>::type));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<joint_view_type, std::string>::type));
BOOST_MPL_ASSERT((boost::fusion::result_of::has_key<joint_view_type, float>::type));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::key_of<boost::fusion::result_of::begin<joint_view_type>::type>::type, void>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::key_of<boost::fusion::result_of::next<boost::fusion::result_of::begin<joint_view_type>::type>::type>::type, std::string>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::key_of<boost::fusion::result_of::next<boost::fusion::result_of::next<boost::fusion::result_of::begin<joint_view_type>::type>::type>::type>::type
, float>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_of_data<boost::fusion::result_of::begin<joint_view_type>::type>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<boost::fusion::result_of::value_of_data<boost::fusion::result_of::next<boost::fusion::result_of::begin<joint_view_type>::type>::type>::type, std::string>));
BOOST_MPL_ASSERT((boost::is_same<
boost::fusion::result_of::value_of_data<boost::fusion::result_of::next<boost::fusion::result_of::next<boost::fusion::result_of::begin<joint_view_type>::type>::type>::type>::type
, float>));
std::cout << deref_data(begin(j)) << std::endl;
std::cout << deref_data(fusion::next(begin(j))) << std::endl;
std::cout << deref_data(fusion::next(fusion::next(begin(j)))) << std::endl;
BOOST_TEST((deref_data(begin(j)) == 0));
BOOST_TEST((deref_data(fusion::next(begin(j))) == "foo"));
BOOST_TEST((deref_data(fusion::next(fusion::next(begin(j)))) == 1.3f));
}
return boost::report_errors();
}

View File

@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/list/list.hpp>
#define FUSION_SEQUENCE list
#include "comparison.hpp"
int
main()
{
equality_test();
ordering_test();
return boost::report_errors();
}

View File

@@ -0,0 +1,18 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/list/list.hpp>
#define FUSION_SEQUENCE list
#include "construction.hpp"
int
main()
{
test();
return boost::report_errors();
}

View File

@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_list.hpp>
#include <boost/fusion/container/generation/list_tie.hpp>
#define FUSION_SEQUENCE list
#include "copy.hpp"
int
main()
{
test<test_detail::can_copy>();
return boost::report_errors();
}

View File

@@ -0,0 +1,16 @@
/*=============================================================================
Copyright (c) 2014 Christoph Weiss
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 "hash.hpp"
int main()
{
hash_test();
return boost::report_errors();
}

View File

@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/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();
}

View File

@@ -0,0 +1,20 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/generation/make_list.hpp>
#define FUSION_SEQUENCE list
#include "make.hpp"
int
main()
{
test();
return boost::report_errors();
}

View File

@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/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();
}

View File

@@ -0,0 +1,19 @@
/*=============================================================================
Copyright (c) 1999-2003 Jaakko Jarvi
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/fusion/container/list/list.hpp>
#define FUSION_SEQUENCE list
#include "mutate.hpp"
int
main()
{
test();
return boost::report_errors();
}

Some files were not shown because too many files have changed in this diff Show More