summaryrefslogtreecommitdiff
path: root/libs/fusion/test/sequence
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-04-08 03:09:47 +0000
committer <>2015-05-05 14:37:32 +0000
commitf2541bb90af059680aa7036f315f052175999355 (patch)
treea5b214744b256f07e1dc2bd7273035a7808c659f /libs/fusion/test/sequence
parented232fdd34968697a68783b3195b1da4226915b5 (diff)
downloadboost-tarball-master.tar.gz
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/fusion/test/sequence')
-rw-r--r--libs/fusion/test/sequence/adapt_adt.cpp147
-rw-r--r--libs/fusion/test/sequence/adapt_adt_named.cpp52
-rw-r--r--libs/fusion/test/sequence/adapt_assoc_adt.cpp57
-rw-r--r--libs/fusion/test/sequence/adapt_assoc_adt_named.cpp4
-rw-r--r--libs/fusion/test/sequence/adapt_assoc_struct.cpp61
-rw-r--r--libs/fusion/test/sequence/adapt_assoc_tpl_adt.cpp63
-rw-r--r--libs/fusion/test/sequence/adapt_assoc_tpl_struct.cpp64
-rw-r--r--libs/fusion/test/sequence/adapt_struct.cpp131
-rw-r--r--libs/fusion/test/sequence/adapt_struct_named.cpp64
-rw-r--r--libs/fusion/test/sequence/adapt_tpl_adt.cpp66
-rw-r--r--libs/fusion/test/sequence/adapt_tpl_struct.cpp63
-rw-r--r--libs/fusion/test/sequence/as_deque.cpp70
-rw-r--r--libs/fusion/test/sequence/as_map_assoc.cpp85
-rw-r--r--libs/fusion/test/sequence/back_extended_deque.cpp39
-rw-r--r--libs/fusion/test/sequence/boost_tuple.cpp10
-rw-r--r--libs/fusion/test/sequence/boost_tuple_iterator.cpp21
-rw-r--r--libs/fusion/test/sequence/cons.cpp7
-rw-r--r--libs/fusion/test/sequence/deduce_sequence.cpp11
-rw-r--r--libs/fusion/test/sequence/define_struct_inline.cpp4
-rw-r--r--libs/fusion/test/sequence/deque_hash.cpp16
-rw-r--r--libs/fusion/test/sequence/front_extended_deque.cpp39
-rw-r--r--libs/fusion/test/sequence/hash.cpp58
-rw-r--r--libs/fusion/test/sequence/hash.hpp34
-rw-r--r--libs/fusion/test/sequence/list_hash.cpp16
-rw-r--r--libs/fusion/test/sequence/map.cpp58
-rw-r--r--libs/fusion/test/sequence/map_misc.cpp12
-rw-r--r--libs/fusion/test/sequence/misc.hpp12
-rw-r--r--libs/fusion/test/sequence/move.hpp4
-rw-r--r--libs/fusion/test/sequence/set.cpp24
-rw-r--r--libs/fusion/test/sequence/size.cpp103
-rw-r--r--libs/fusion/test/sequence/std_tuple.cpp46
-rw-r--r--libs/fusion/test/sequence/std_tuple_iterator.cpp3
-rw-r--r--libs/fusion/test/sequence/test_deduce_sequence.cpp6
-rw-r--r--libs/fusion/test/sequence/tr1_tuple_auto_conv.cpp56
-rw-r--r--libs/fusion/test/sequence/tuple_hash.cpp16
-rw-r--r--libs/fusion/test/sequence/vector_hash.cpp16
36 files changed, 1241 insertions, 297 deletions
diff --git a/libs/fusion/test/sequence/adapt_adt.cpp b/libs/fusion/test/sequence/adapt_adt.cpp
index d4f4a8c27..265cfca59 100644
--- a/libs/fusion/test/sequence/adapt_adt.cpp
+++ b/libs/fusion/test/sequence/adapt_adt.cpp
@@ -38,18 +38,21 @@ namespace ns
{
public:
- point() : x(0), y(0) {}
- point(int in_x, int in_y) : x(in_x), y(in_y) {}
+ 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)
@@ -58,17 +61,22 @@ namespace ns
friend struct boost::fusion::extension::access;
public:
- point_with_private_members() : x(0), y(0) {}
- point_with_private_members(int x, int y) : x(x), y(y) {}
-
- private:
+ 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
@@ -91,25 +99,55 @@ namespace ns
};
}
-BOOST_FUSION_ADAPT_ADT(
- ns::point,
- (int, int, obj.get_x(), obj.set_x(val))
- (int, int, obj.get_y(), obj.set_y(val))
-)
+#if BOOST_PP_VARIADICS
+ BOOST_FUSION_ADAPT_ADT(
+ ns::point,
+ (int, int, obj.get_x(), obj.set_x(val))
+ (BOOST_FUSION_ADAPT_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,
- (int, int, obj.get_x(), obj.set_x(val))
- (int, int, obj.get_y(), obj.set_y(val))
-)
-#endif
+# 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))
+ (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_y(), obj.set_y(val))
+ (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val))
+ )
+
+# if !BOOST_WORKAROUND(__GNUC__,<4)
+ BOOST_FUSION_ADAPT_ADT(
+ ns::point_with_private_members,
+ (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_x(), obj.set_x(val))
+ (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_y(), obj.set_y(val))
+ (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_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, BOOST_FUSION_ADAPT_AUTO, obj.get_first(), obj.set_first(val))
+ )
-BOOST_FUSION_ADAPT_ADT(
- ns::name,
- (const std::string&, const std::string&, obj.get_last(), obj.set_last(val))
- (const std::string&, const std::string&, obj.get_first(), obj.set_first(val))
-)
+#endif
int
main()
@@ -123,28 +161,30 @@ main()
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
- ns::point p(123, 456);
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 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 == 2);
+ 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) == 9);
+ BOOST_TEST(back(p) == 12);
}
{
- fusion::vector<int, float> v1(4, 2);
- ns::point v2(5, 3);
- fusion::vector<long, double> v3(5, 4);
+ fusion::vector<int, float, int> v1(4, 2, 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);
@@ -171,15 +211,15 @@ main()
{
// conversion from ns::point to vector
- ns::point p(5, 3);
- fusion::vector<int, long> v(p);
+ 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);
- fusion::list<int, long> l(p);
+ ns::point p(5, 3, 3);
+ fusion::list<int, long, int> l(p);
l = p;
}
@@ -193,26 +233,29 @@ main()
#if !BOOST_WORKAROUND(__GNUC__,<4)
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point_with_private_members>));
- ns::point_with_private_members p(123, 456);
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 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 == 2);
+ 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) == 9);
+ 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,
@@ -233,6 +276,28 @@ main()
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,
+ const int
+ >));
}
return boost::report_errors();
diff --git a/libs/fusion/test/sequence/adapt_adt_named.cpp b/libs/fusion/test/sequence/adapt_adt_named.cpp
index 384156337..8924ce41c 100644
--- a/libs/fusion/test/sequence/adapt_adt_named.cpp
+++ b/libs/fusion/test/sequence/adapt_adt_named.cpp
@@ -37,28 +37,46 @@ namespace ns
{
public:
- point() : x(0), y(0) {}
- point(int in_x, int in_y) : x(in_x), y(in_y) {}
+ 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.obj.get_x(), obj.obj.set_x(val))
- (int, int, obj.obj.get_y(), obj.obj.set_y(val))
+ (int, int, obj.get_x(), obj.set_x(val))
+ (int, int, obj.get_y(), obj.set_y(val))
+ (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val))
)
+#endif // BOOST_PP_VARIADICS
+
int
main()
{
@@ -71,31 +89,33 @@ main()
{
BOOST_MPL_ASSERT((traits::is_view<adapted::point>));
- ns::point basep(123, 456);
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 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 == 2);
+ 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) == 9);
+ BOOST_TEST(back(p) == 12);
}
{
- fusion::vector<int, float> v1(4, 2);
- ns::point basep(5, 3);
+ fusion::vector<int, float, int> v1(4, 2, 2);
+ ns::point basep(5, 3, 3);
adapted::point v2(basep);
- fusion::vector<long, double> v3(5, 4);
+ fusion::vector<long, double, int> v3(5, 4, 4);
BOOST_TEST(v1 < v2);
BOOST_TEST(v1 <= v2);
BOOST_TEST(v2 > v1);
@@ -108,19 +128,19 @@ main()
{
// conversion from ns::point to vector
- ns::point basep(5, 3);
+ ns::point basep(5, 3, 3);
adapted::point p(basep);
- fusion::vector<int, long> v(p);
+ fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from ns::point to list
- ns::point basep(5, 3);
+ ns::point basep(5, 3, 3);
adapted::point p(basep);
- fusion::list<int, long> l(p);
+ fusion::list<int, long, float> l(p);
l = p;
}
diff --git a/libs/fusion/test/sequence/adapt_assoc_adt.cpp b/libs/fusion/test/sequence/adapt_assoc_adt.cpp
index c97e84b0a..a03605f1e 100644
--- a/libs/fusion/test/sequence/adapt_assoc_adt.cpp
+++ b/libs/fusion/test/sequence/adapt_assoc_adt.cpp
@@ -26,31 +26,50 @@ namespace ns
struct y_member;
struct z_member;
+ struct non_member;
+
class point
{
public:
- point() : x(0), y(0) {}
- point(int in_x, int in_y) : x(in_x), y(in_y) {}
+ 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)
+ (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val), ns::z_member)
+)
+
+#endif
+
int
main()
{
@@ -62,28 +81,30 @@ main()
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
- ns::point p(123, 456);
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 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 == 2);
+ 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) == 9);
+ BOOST_TEST(back(p) == 12);
}
{
- boost::fusion::vector<int, float> v1(4, 2);
- ns::point v2(5, 3);
- boost::fusion::vector<long, double> v3(5, 4);
+ boost::fusion::vector<int, float, int> v1(4, 2, 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);
@@ -96,15 +117,15 @@ main()
{
// conversion from ns::point to vector
- ns::point p(5, 3);
- boost::fusion::vector<int, long> v(p);
+ 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);
- boost::fusion::list<int, long> l(p);
+ ns::point p(5, 3, 3);
+ boost::fusion::list<int, long, int> l(p);
l = p;
}
@@ -119,15 +140,19 @@ main()
// 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::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);
+ 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();
diff --git a/libs/fusion/test/sequence/adapt_assoc_adt_named.cpp b/libs/fusion/test/sequence/adapt_assoc_adt_named.cpp
index d68d99040..8ef9aa27b 100644
--- a/libs/fusion/test/sequence/adapt_assoc_adt_named.cpp
+++ b/libs/fusion/test/sequence/adapt_assoc_adt_named.cpp
@@ -48,8 +48,8 @@ namespace ns
BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(
ns::point,
point,
- (int, int, obj.obj.get_x(), obj.obj.set_x(val), ns::x_member)
- (int, int, obj.obj.get_y(), obj.obj.set_y(val), ns::y_member)
+ (int, int, obj.get_x(), obj.set_x(val), ns::x_member)
+ (int, int, obj.get_y(), obj.set_y(val), ns::y_member)
)
int
diff --git a/libs/fusion/test/sequence/adapt_assoc_struct.cpp b/libs/fusion/test/sequence/adapt_assoc_struct.cpp
index 62574a7ec..4cdabb878 100644
--- a/libs/fusion/test/sequence/adapt_assoc_struct.cpp
+++ b/libs/fusion/test/sequence/adapt_assoc_struct.cpp
@@ -30,6 +30,7 @@
#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>
@@ -42,19 +43,33 @@ namespace ns
struct x_member;
struct y_member;
struct z_member;
+ struct non_member;
struct point
{
int x;
int y;
+ int z;
};
}
-BOOST_FUSION_ADAPT_ASSOC_STRUCT(
- ns::point,
- (int, x, ns::x_member)
- (int, y, ns::y_member)
-)
+#if BOOST_PP_VARIADICS
+ BOOST_FUSION_ADAPT_ASSOC_STRUCT(
+ ns::point,
+ (x, ns::x_member)
+ (y, ns::y_member)
+ (int, z, ns::z_member)
+ )
+
+#else // BOOST_PP_VARIADICS
+ BOOST_FUSION_ADAPT_ASSOC_STRUCT(
+ ns::point,
+ (BOOST_FUSION_ADAPT_AUTO, x, ns::x_member)
+ (BOOST_FUSION_ADAPT_AUTO, y, ns::y_member)
+ (int, z, ns::z_member)
+ )
+
+#endif
int
main()
@@ -68,28 +83,30 @@ main()
{
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
- ns::point p = {123, 456};
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 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 == 2);
+ 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) == 9);
+ BOOST_TEST(back(p) == 12);
}
{
- fusion::vector<int, float> v1(4, 2);
- ns::point v2 = {5, 3};
- fusion::vector<long, double> v3(5, 4);
+ fusion::vector<int, float, int> v1(4, 2, 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);
@@ -102,15 +119,15 @@ main()
{
// conversion from ns::point to vector
- ns::point p = {5, 3};
- fusion::vector<int, long> v(p);
+ 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};
- fusion::list<int, long> l(p);
+ ns::point p = {5, 3, 3};
+ fusion::list<int, long, int> l(p);
l = p;
}
@@ -118,15 +135,18 @@ main()
// 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((mpl::not_<boost::fusion::result_of::has_key<ns::point, ns::z_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};
+ 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);
}
{
@@ -134,6 +154,9 @@ main()
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();
diff --git a/libs/fusion/test/sequence/adapt_assoc_tpl_adt.cpp b/libs/fusion/test/sequence/adapt_assoc_tpl_adt.cpp
index 15e2124cb..8aa600ff6 100644
--- a/libs/fusion/test/sequence/adapt_assoc_tpl_adt.cpp
+++ b/libs/fusion/test/sequence/adapt_assoc_tpl_adt.cpp
@@ -26,39 +26,57 @@ namespace ns
struct y_member;
struct z_member;
- template<typename X, typename Y>
+ struct non_member;
+
+ template<typename X, typename Y, typename Z>
class point
{
public:
- point() : x(0), y(0) {}
- point(X in_x, Y in_y) : x(in_x), y(in_y) {}
+ 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),
- (ns::point)(X)(Y),
+ (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)
+ (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val), ns::z_member)
)
+#endif
+
int
main()
{
using namespace boost::fusion;
- typedef ns::point<int,int> point;
+ typedef ns::point<int,int,long> point;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
@@ -66,28 +84,30 @@ main()
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
- point p(123, 456);
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 9));
+ at_c<2>(p) = 12;
+ BOOST_TEST(p == make_vector(6, 9, 12));
- BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 2);
+ 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) == 9);
+ BOOST_TEST(back(p) == 12);
}
{
- boost::fusion::vector<int, float> v1(4, 2);
- point v2(5, 3);
- boost::fusion::vector<long, double> v3(5, 4);
+ boost::fusion::vector<int, float, long> v1(4, 2, 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);
@@ -100,15 +120,15 @@ main()
{
// conversion from point to vector
- point p(5, 3);
- boost::fusion::vector<int, long> v(p);
+ point p(5, 3, 3);
+ boost::fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from point to list
- point p(5, 3);
- boost::fusion::list<int, long> l(p);
+ point p(5, 3, 3);
+ boost::fusion::list<int, long, int> l(p);
l = p;
}
@@ -123,15 +143,18 @@ main()
// 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::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);
+ 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();
diff --git a/libs/fusion/test/sequence/adapt_assoc_tpl_struct.cpp b/libs/fusion/test/sequence/adapt_assoc_tpl_struct.cpp
index a327f9e87..6adcc9312 100644
--- a/libs/fusion/test/sequence/adapt_assoc_tpl_struct.cpp
+++ b/libs/fusion/test/sequence/adapt_assoc_tpl_struct.cpp
@@ -39,27 +39,42 @@ namespace ns
struct y_member;
struct z_member;
- template<typename X, typename Y>
+ struct non_member;
+
+ template<typename X, typename Y, typename Z>
struct point
{
X x;
Y y;
+ Z z;
};
}
-BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT(
- (X)(Y),
- (ns::point)(X)(Y),
- (int, x, ns::x_member)
- (int, y, ns::y_member)
-)
+#if 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)
+ (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)
+ (BOOST_FUSION_ADAPT_AUTO, z, ns::z_member)
+ )
+#endif
int
main()
{
using namespace boost::fusion;
- typedef ns::point<int,int> point;
+ typedef ns::point<int,int,float> point;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
@@ -67,28 +82,30 @@ main()
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
- point p = {123, 456};
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789.43f));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 9));
+ at_c<2>(p) = 12;
+ BOOST_TEST(p == make_vector(6, 9, 12));
- BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 2);
+ 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) == 9);
+ BOOST_TEST(back(p) == 12);
}
{
- vector<int, float> v1(4, 2);
- point v2 = {5, 3};
- vector<long, double> v3(5, 4);
+ vector<int, float, int> v1(4, 2, 2);
+ point v2 = {5, 3, 3};
+ vector<long, double, float> v3(5, 4, 4.13f);
BOOST_TEST(v1 < v2);
BOOST_TEST(v1 <= v2);
BOOST_TEST(v2 > v1);
@@ -101,15 +118,15 @@ main()
{
// conversion from point to vector
- point p = {5, 3};
- vector<int, long> v(p);
+ point p = {5, 3, 3};
+ vector<int, long, int> v(p);
v = p;
}
{
// conversion from point to list
- point p = {5, 3};
- list<int, long> l(p);
+ point p = {5, 3, 3};
+ list<int, long, int> l(p);
l = p;
}
@@ -117,15 +134,18 @@ main()
// 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::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};
+ 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);
}
return boost::report_errors();
diff --git a/libs/fusion/test/sequence/adapt_struct.cpp b/libs/fusion/test/sequence/adapt_struct.cpp
index 68240463c..c0cd30494 100644
--- a/libs/fusion/test/sequence/adapt_struct.cpp
+++ b/libs/fusion/test/sequence/adapt_struct.cpp
@@ -38,6 +38,7 @@ namespace ns
{
int x;
int y;
+ int z;
};
#if !BOOST_WORKAROUND(__GNUC__,<4)
@@ -48,65 +49,119 @@ namespace ns
private:
int x;
int y;
+ int z;
public:
- point_with_private_attributes(int x, int y):x(x),y(y)
+ 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;
+ };
}
-BOOST_FUSION_ADAPT_STRUCT(
- ns::point,
- (int, x)
- (int, y)
-)
+#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
+ y
+ )
+
+#else // BOOST_PP_VARIADICS
+
+ BOOST_FUSION_ADAPT_STRUCT(
+ ns::point,
+ (int, x)
+ (int, y)
+ (BOOST_FUSION_ADAPT_AUTO, z)
+ )
+
+# if !BOOST_WORKAROUND(__GNUC__,<4)
+ BOOST_FUSION_ADAPT_STRUCT(
+ ns::point_with_private_attributes,
+ (int, x)
+ (int, y)
+ (BOOST_FUSION_ADAPT_AUTO, z)
+ )
+# endif
+
+ struct s { int m; };
+ BOOST_FUSION_ADAPT_STRUCT(s, (BOOST_FUSION_ADAPT_AUTO, m))
+
+ BOOST_FUSION_ADAPT_STRUCT(
+ ns::bar,
+ (BOOST_FUSION_ADAPT_AUTO, foo_.x) // test that adapted members can actually be expressions
+ (BOOST_FUSION_ADAPT_AUTO, y)
+ )
-#if !BOOST_WORKAROUND(__GNUC__,<4)
-BOOST_FUSION_ADAPT_STRUCT(
- ns::point_with_private_attributes,
- (int, x)
- (int, y)
-)
#endif
-struct s { int m; };
-BOOST_FUSION_ADAPT_STRUCT(s, (int, m))
-
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<ns::point>));
- ns::point p = {123, 456};
+ BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 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 == 2);
- BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<ns::point>::value);
+ 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) == 9);
+ BOOST_TEST(back(p) == 12);
}
{
- fusion::vector<int, float> v1(4, 2);
- ns::point v2 = {5, 3};
- fusion::vector<long, double> v3(5, 4);
+ vector<int, float, int> v1(4, 2, 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);
@@ -118,16 +173,16 @@ main()
}
{
- // conversion from ns::point to vector
- ns::point p = {5, 3};
- fusion::vector<int, long> v(p);
+ // conversion from point to vector
+ point p = {5, 3, 3};
+ vector<int, long, int> v(p);
v = p;
}
{
- // conversion from ns::point to list
- ns::point p = {5, 3};
- fusion::list<int, long> l(p);
+ // conversion from point to list
+ point p = {5, 3, 3};
+ list<int, long, int> l(p);
l = p;
}
@@ -150,15 +205,25 @@ main()
#if !BOOST_WORKAROUND(__GNUC__,<4)
{
- ns::point_with_private_attributes p(123, 456);
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
}
#endif
+ {
+ fusion::vector<int, float> v1(4, 2);
+ ns::bar v2 = {{5}, 3};
+ BOOST_TEST(v1 < v2);
+ BOOST_TEST(v1 <= v2);
+ BOOST_TEST(v2 > v1);
+ BOOST_TEST(v2 >= v1);
+ }
+
return boost::report_errors();
}
diff --git a/libs/fusion/test/sequence/adapt_struct_named.cpp b/libs/fusion/test/sequence/adapt_struct_named.cpp
index ef859655b..aab11d2dc 100644
--- a/libs/fusion/test/sequence/adapt_struct_named.cpp
+++ b/libs/fusion/test/sequence/adapt_struct_named.cpp
@@ -37,19 +37,39 @@ namespace ns
{
int x;
int y;
+ int z;
};
}
-// this creates a fusion view: boost::fusion::adapted::point
-BOOST_FUSION_ADAPT_STRUCT_NAMED(
- ns::point, point,
- (int, x)
- (int, y)
-)
+#if BOOST_PP_VARIADICS
-// this creates a fusion view: ns1::s1
-struct s { int m; };
-BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(s, (ns1), s1, (int, m))
+ // 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)
+ (int, y)
+ (BOOST_FUSION_ADAPT_AUTO, z)
+ )
+
+ // this creates a fusion view: ns1::s1
+ struct s { int m; };
+ BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(s, (ns1), s1, (BOOST_FUSION_ADAPT_AUTO, m))
+
+#endif
int
main()
@@ -63,31 +83,33 @@ main()
{
BOOST_MPL_ASSERT((traits::is_view<adapted::point>));
- ns::point basep = {123, 456};
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 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 == 2);
+ 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) == 9);
+ BOOST_TEST(back(p) == 12);
}
{
- fusion::vector<int, float> v1(4, 2);
- ns::point p = {5, 3};
+ fusion::vector<int, float, int> v1(4, 2, 2);
+ ns::point p = {5, 3, 3};
adapted::point v2(p);
- fusion::vector<long, double> v3(5, 4);
+ fusion::vector<long, double, int> v3(5, 4, 4);
BOOST_TEST(v1 < v2);
BOOST_TEST(v1 <= v2);
BOOST_TEST(v2 > v1);
@@ -100,17 +122,17 @@ main()
{
// conversion from adapted::point to vector
- ns::point basep = {5, 3};
+ ns::point basep = {5, 3, 3};
adapted::point p(basep);
- fusion::vector<int, long> v(p);
+ fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from adapted::point to list
- ns::point basep = {5, 3};
+ ns::point basep = {5, 3, 3};
adapted::point p(basep);
- fusion::list<int, long> l(p);
+ fusion::list<int, long, int> l(p);
l = p;
}
diff --git a/libs/fusion/test/sequence/adapt_tpl_adt.cpp b/libs/fusion/test/sequence/adapt_tpl_adt.cpp
index aeb0f7215..bbd1d07fe 100644
--- a/libs/fusion/test/sequence/adapt_tpl_adt.cpp
+++ b/libs/fusion/test/sequence/adapt_tpl_adt.cpp
@@ -39,27 +39,45 @@ namespace ns
{
public:
- point() : x(0), y(0) {}
- point(X x_, Y y_) : x(x_), y(y_) {}
+ 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;
};
}
-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))
-)
+
+#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))
+ (BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val))
+ )
+#endif
int
main()
@@ -75,28 +93,30 @@ main()
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
- point p(123, 456);
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 9));
+ at_c<2>(p) = 12;
+ BOOST_TEST(p == make_vector(6, 9, 12));
- BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 2);
+ 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) == 9);
+ BOOST_TEST(back(p) == 12);
}
{
- boost::fusion::vector<int, float> v1(4, 2);
- point v2(5, 3);
- boost::fusion::vector<long, double> v3(5, 4);
+ boost::fusion::vector<int, float, int> v1(4, 2, 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);
@@ -108,9 +128,9 @@ main()
}
{
- boost::fusion::vector<std::string, std::string> v1("Lincoln", "Abraham");
- name v2("Roosevelt", "Franklin");
- name v3("Roosevelt", "Theodore");
+ 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);
@@ -123,15 +143,15 @@ main()
{
// conversion from point to vector
- point p(5, 3);
- boost::fusion::vector<int, long> v(p);
+ point p(5, 3, 3);
+ boost::fusion::vector<int, long, int> v(p);
v = p;
}
{
// conversion from point to list
- point p(5, 3);
- boost::fusion::list<int, long> l(p);
+ point p(5, 3, 3);
+ boost::fusion::list<int, long, int> l(p);
l = p;
}
diff --git a/libs/fusion/test/sequence/adapt_tpl_struct.cpp b/libs/fusion/test/sequence/adapt_tpl_struct.cpp
index 352cf9957..86face6d4 100644
--- a/libs/fusion/test/sequence/adapt_tpl_struct.cpp
+++ b/libs/fusion/test/sequence/adapt_tpl_struct.cpp
@@ -35,19 +35,40 @@ namespace ns
{
X x;
Y y;
+ int z;
};
}
-BOOST_FUSION_ADAPT_TPL_STRUCT(
- (X)(Y),
- (ns::point)(X)(Y),
- (X, x)
- (Y, y)
-)
+#if BOOST_PP_VARIADICS
+
+ BOOST_FUSION_ADAPT_TPL_STRUCT(
+ (X)(Y),
+ (ns::point)(X)(Y),
+ x,
+ (BOOST_FUSION_ADAPT_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)
+ (BOOST_FUSION_ADAPT_AUTO, z)
+ )
+
+ template<typename M>
+ struct s { M m; };
+ BOOST_FUSION_ADAPT_TPL_STRUCT((M), (s)(M), (BOOST_FUSION_ADAPT_AUTO, m))
+
+#endif
-template<typename M>
-struct s { M m; };
-BOOST_FUSION_ADAPT_TPL_STRUCT((M), (s)(M), (M, m))
int
main()
@@ -62,28 +83,30 @@ main()
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
- point p = {123, 456};
+ 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));
+ BOOST_TEST(p == make_vector(123, 456, 789));
at_c<0>(p) = 6;
at_c<1>(p) = 9;
- BOOST_TEST(p == make_vector(6, 9));
+ at_c<2>(p) = 12;
+ BOOST_TEST(p == make_vector(6, 9, 12));
- BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 2);
+ 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) == 9);
+ BOOST_TEST(back(p) == 12);
}
{
- vector<int, float> v1(4, 2);
- point v2 = {5, 3};
- vector<long, double> v3(5, 4);
+ vector<int, float, int> v1(4, 2, 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);
@@ -96,14 +119,14 @@ main()
{
// conversion from point to vector
- point p = {5, 3};
- vector<int, long> v(p);
+ point p = {5, 3, 3};
+ vector<int, long, int> v(p);
v = p;
}
{
// conversion from point to list
- point p = {5, 3};
+ point p = {5, 3, 3};
list<int, long> l(p);
l = p;
}
diff --git a/libs/fusion/test/sequence/as_deque.cpp b/libs/fusion/test/sequence/as_deque.cpp
new file mode 100644
index 000000000..c56c598dd
--- /dev/null
+++ b/libs/fusion/test/sequence/as_deque.cpp
@@ -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();
+}
diff --git a/libs/fusion/test/sequence/as_map_assoc.cpp b/libs/fusion/test/sequence/as_map_assoc.cpp
new file mode 100644
index 000000000..bc9a6951c
--- /dev/null
+++ b/libs/fusion/test/sequence/as_map_assoc.cpp
@@ -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();
+}
+
diff --git a/libs/fusion/test/sequence/back_extended_deque.cpp b/libs/fusion/test/sequence/back_extended_deque.cpp
index edae9276c..368ec0c26 100644
--- a/libs/fusion/test/sequence/back_extended_deque.cpp
+++ b/libs/fusion/test/sequence/back_extended_deque.cpp
@@ -24,6 +24,45 @@ 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;
diff --git a/libs/fusion/test/sequence/boost_tuple.cpp b/libs/fusion/test/sequence/boost_tuple.cpp
index c16c08940..7d19ffef3 100644
--- a/libs/fusion/test/sequence/boost_tuple.cpp
+++ b/libs/fusion/test/sequence/boost_tuple.cpp
@@ -23,6 +23,7 @@
#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>
@@ -87,7 +88,14 @@ main()
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
diff --git a/libs/fusion/test/sequence/boost_tuple_iterator.cpp b/libs/fusion/test/sequence/boost_tuple_iterator.cpp
new file mode 100644
index 000000000..3ab096b9b
--- /dev/null
+++ b/libs/fusion/test/sequence/boost_tuple_iterator.cpp
@@ -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();
+}
+
diff --git a/libs/fusion/test/sequence/cons.cpp b/libs/fusion/test/sequence/cons.cpp
index cb74af619..88a04101c 100644
--- a/libs/fusion/test/sequence/cons.cpp
+++ b/libs/fusion/test/sequence/cons.cpp
@@ -16,6 +16,7 @@
#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>
@@ -83,6 +84,12 @@ main()
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();
}
diff --git a/libs/fusion/test/sequence/deduce_sequence.cpp b/libs/fusion/test/sequence/deduce_sequence.cpp
index ea6616627..a1569f46f 100644
--- a/libs/fusion/test/sequence/deduce_sequence.cpp
+++ b/libs/fusion/test/sequence/deduce_sequence.cpp
@@ -6,6 +6,7 @@
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>
@@ -13,6 +14,9 @@
#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;
@@ -66,6 +70,13 @@ int main()
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]);
diff --git a/libs/fusion/test/sequence/define_struct_inline.cpp b/libs/fusion/test/sequence/define_struct_inline.cpp
index 9cbd8ea0c..e849ce9b1 100644
--- a/libs/fusion/test/sequence/define_struct_inline.cpp
+++ b/libs/fusion/test/sequence/define_struct_inline.cpp
@@ -1,8 +1,8 @@
/*=============================================================================
Copyright (c) 2010, 2012 Christopher Schmidt, Nathan Ridge
- Distributed under the Boost Software Liceclse, Version 1.0. (See accompanying
- file LICEclsE_1_0.txt or copy at http://www.boost.org/LICEclsE_1_0.txt)
+ 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>
diff --git a/libs/fusion/test/sequence/deque_hash.cpp b/libs/fusion/test/sequence/deque_hash.cpp
new file mode 100644
index 000000000..01b36660a
--- /dev/null
+++ b/libs/fusion/test/sequence/deque_hash.cpp
@@ -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();
+}
diff --git a/libs/fusion/test/sequence/front_extended_deque.cpp b/libs/fusion/test/sequence/front_extended_deque.cpp
index d1c903432..cdbedeb3b 100644
--- a/libs/fusion/test/sequence/front_extended_deque.cpp
+++ b/libs/fusion/test/sequence/front_extended_deque.cpp
@@ -24,6 +24,45 @@ 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;
diff --git a/libs/fusion/test/sequence/hash.cpp b/libs/fusion/test/sequence/hash.cpp
new file mode 100644
index 000000000..3740bf550
--- /dev/null
+++ b/libs/fusion/test/sequence/hash.cpp
@@ -0,0 +1,58 @@
+/*=============================================================================
+ 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/detail/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));
+}
diff --git a/libs/fusion/test/sequence/hash.hpp b/libs/fusion/test/sequence/hash.hpp
new file mode 100644
index 000000000..7dea0a3f0
--- /dev/null
+++ b/libs/fusion/test/sequence/hash.hpp
@@ -0,0 +1,34 @@
+/*=============================================================================
+ 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 <utility>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/sequence/hash.hpp>
+#include <boost/functional/hash.hpp>
+
+void
+hash_test()
+{
+ using namespace boost::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(hash_value(v0) == hash_value(v1));
+
+ const FUSION_SEQUENCE<int, char, bool, std::string> w(41, 'x', false, "Aurea prima");
+ BOOST_TEST(hash_value(w) != hash_value(v0));
+
+ const FUSION_SEQUENCE<int, char, bool, std::string> x(42, 'y', false, "Aurea prima");
+ BOOST_TEST(hash_value(x) != hash_value(v0));
+
+ const FUSION_SEQUENCE<int, char, bool, std::string> y(42, 'x', true, "Aurea prima");
+ BOOST_TEST(hash_value(y) != hash_value(v0));
+
+ const FUSION_SEQUENCE<int, char, bool, std::string> z(42, 'x', false, "quae vindice nullo");
+ BOOST_TEST(hash_value(z) != hash_value(v0));
+}
diff --git a/libs/fusion/test/sequence/list_hash.cpp b/libs/fusion/test/sequence/list_hash.cpp
new file mode 100644
index 000000000..51203b273
--- /dev/null
+++ b/libs/fusion/test/sequence/list_hash.cpp
@@ -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();
+}
diff --git a/libs/fusion/test/sequence/map.cpp b/libs/fusion/test/sequence/map.cpp
index 58497b44d..8dada1675 100644
--- a/libs/fusion/test/sequence/map.cpp
+++ b/libs/fusion/test/sequence/map.cpp
@@ -25,6 +25,24 @@
#include <iostream>
#include <string>
+
+struct copy_all
+{
+ copy_all() {}
+ copy_all(copy_all const&) {}
+
+ template <typename T>
+ copy_all(T const& x)
+ {
+ foo(x); // should fail!
+ }
+};
+
+struct abstract
+{
+ virtual void foo() = 0;
+};
+
int
main()
{
@@ -41,7 +59,8 @@ main()
{
typedef map<
pair<int, char>
- , pair<double, std::string> >
+ , pair<double, std::string>
+ , pair<abstract, int> >
map_type;
BOOST_MPL_ASSERT((traits::is_associative<map_type>));
@@ -49,23 +68,29 @@ main()
map_type m(
make_pair<int>('X')
- , make_pair<double>("Men"));
+ , make_pair<double>("Men")
+ , make_pair<abstract>(2));
std::cout << at_key<int>(m) << std::endl;
std::cout << at_key<double>(m) << std::endl;
+ std::cout << at_key<abstract>(m) << std::endl;
BOOST_TEST(at_key<int>(m) == 'X');
BOOST_TEST(at_key<double>(m) == "Men");
+ BOOST_TEST(at_key<abstract>(m) == 2);
BOOST_STATIC_ASSERT((
boost::is_same<boost::fusion::result_of::value_at_key<map_type, int>::type, char>::value));
BOOST_STATIC_ASSERT((
boost::is_same<boost::fusion::result_of::value_at_key<map_type, double>::type, std::string>::value));
+ BOOST_STATIC_ASSERT((
+ boost::is_same<boost::fusion::result_of::value_at_key<map_type, abstract>::type, int>::value));
std::cout << m << std::endl;
BOOST_STATIC_ASSERT((boost::fusion::result_of::has_key<map_type, int>::value));
BOOST_STATIC_ASSERT((boost::fusion::result_of::has_key<map_type, double>::value));
+ BOOST_STATIC_ASSERT((boost::fusion::result_of::has_key<map_type, abstract>::value));
BOOST_STATIC_ASSERT((!boost::fusion::result_of::has_key<map_type, std::string>::value));
std::cout << deref_data(begin(m)) << std::endl;
@@ -73,15 +98,19 @@ main()
BOOST_TEST(deref_data(begin(m)) == 'X');
BOOST_TEST(deref_data(fusion::next(begin(m))) == "Men");
+ BOOST_TEST(deref_data(fusion::next(next(begin(m)))) == 2);
BOOST_STATIC_ASSERT((boost::is_same<boost::fusion::result_of::key_of<boost::fusion::result_of::begin<map_type>::type>::type, int>::value));
BOOST_STATIC_ASSERT((boost::is_same<boost::fusion::result_of::key_of<boost::fusion::result_of::next<boost::fusion::result_of::begin<map_type>::type>::type>::type, double>::value));
+ BOOST_STATIC_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<map_type>::type>::type>::type>::type, abstract>::value));
BOOST_STATIC_ASSERT((boost::is_same<boost::fusion::result_of::value_of_data<boost::fusion::result_of::begin<map_type>::type>::type, char>::value));
BOOST_STATIC_ASSERT((boost::is_same<boost::fusion::result_of::value_of_data<boost::fusion::result_of::next<boost::fusion::result_of::begin<map_type>::type>::type>::type, std::string>::value));
+ BOOST_STATIC_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<map_type>::type>::type>::type>::type, int>::value));
// Test random access interface.
pair<int, char> a = at_c<0>(m); (void) a;
pair<double, std::string> b = at_c<1>(m);
+ pair<abstract, int> c = at_c<2>(m);
}
// iterators & random access interface.
@@ -119,6 +148,31 @@ main()
BOOST_TEST(at_key<char>(make_map<char, int>('X', 123)) == 'X');
BOOST_TEST(at_key<int>(make_map<char, int>('X', 123)) == 123);
}
+
+ {
+ // test for copy construction of fusion pairs
+ // make sure that the correct constructor is called
+ pair<int, copy_all> p1;
+ pair<int, copy_all> p2 = p1;
+ }
+
+ {
+ // compile test only
+ // make sure result_of::deref_data returns a reference
+ typedef map<pair<float, int> > map_type;
+ typedef boost::fusion::result_of::begin<map_type>::type i_type;
+ typedef boost::fusion::result_of::deref_data<i_type>::type r_type;
+ BOOST_STATIC_ASSERT((boost::is_same<r_type, int&>::value));
+ }
+
+ {
+ // compile test only
+ // make sure result_of::deref_data is const correct
+ typedef map<pair<float, int> > const map_type;
+ typedef boost::fusion::result_of::begin<map_type>::type i_type;
+ typedef boost::fusion::result_of::deref_data<i_type>::type r_type;
+ BOOST_STATIC_ASSERT((boost::is_same<r_type, int const&>::value));
+ }
return boost::report_errors();
}
diff --git a/libs/fusion/test/sequence/map_misc.cpp b/libs/fusion/test/sequence/map_misc.cpp
index 256a16f4f..81da97539 100644
--- a/libs/fusion/test/sequence/map_misc.cpp
+++ b/libs/fusion/test/sequence/map_misc.cpp
@@ -16,6 +16,7 @@
#include <boost/mpl/equal.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/integral_c.hpp>
+#include <boost/mpl/is_sequence.hpp>
#include <boost/type_traits/is_same.hpp>
#include <string>
@@ -148,6 +149,17 @@ test()
BOOST_STATIC_ASSERT(!traits::is_sequence<char>::value);
}
+ { // testing mpl::is_sequence
+
+ typedef map<pair<k1, int>, pair<k2, float>, pair<k3, double> > t1;
+ typedef map<> t2;
+ typedef map<pair<k1, char> > t3;
+
+ BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t1>::value);
+ BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t2>::value);
+ BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t3>::value);
+ }
+
{ // testing mpl compatibility
// test an algorithm
diff --git a/libs/fusion/test/sequence/misc.hpp b/libs/fusion/test/sequence/misc.hpp
index ecbe15494..c426bba8a 100644
--- a/libs/fusion/test/sequence/misc.hpp
+++ b/libs/fusion/test/sequence/misc.hpp
@@ -13,6 +13,7 @@
#include <boost/mpl/equal.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/integral_c.hpp>
+#include <boost/mpl/is_sequence.hpp>
#include <boost/type_traits/is_same.hpp>
#include <string>
@@ -175,6 +176,17 @@ test()
BOOST_STATIC_ASSERT(!traits::is_sequence<char>::value);
}
+ { // testing mpl::is_sequence
+
+ typedef FUSION_SEQUENCE<int, float, double> t1;
+ typedef FUSION_SEQUENCE<> t2;
+ typedef FUSION_SEQUENCE<char> t3;
+
+ BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t1>::value);
+ BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t2>::value);
+ BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t3>::value);
+ }
+
{ // testing mpl compatibility
// test begin, end, next, prior, advance, size, deref, etc.
diff --git a/libs/fusion/test/sequence/move.hpp b/libs/fusion/test/sequence/move.hpp
index febbc2bba..8636604f1 100644
--- a/libs/fusion/test/sequence/move.hpp
+++ b/libs/fusion/test/sequence/move.hpp
@@ -38,12 +38,12 @@ namespace test_detail
return *this;
}
- x(x const& rhs)
+ x(x const& /*rhs*/)
{
incr_copy();
}
- x& operator=(x const& rhs)
+ x& operator=(x const& /*rhs*/)
{
incr_copy();
return *this;
diff --git a/libs/fusion/test/sequence/set.cpp b/libs/fusion/test/sequence/set.cpp
index 1ea6ba241..cf97c100f 100644
--- a/libs/fusion/test/sequence/set.cpp
+++ b/libs/fusion/test/sequence/set.cpp
@@ -18,8 +18,10 @@
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/support/pair.hpp>
#include <boost/fusion/support/category_of.hpp>
+#include <boost/fusion/support/is_sequence.hpp>
#include <boost/static_assert.hpp>
#include <boost/mpl/assert.hpp>
+#include <boost/mpl/is_sequence.hpp>
#include <iostream>
#include <string>
@@ -78,6 +80,28 @@ main()
BOOST_TEST(at_key<int>(make_set('X', 123)) == 123);
}
+ { // testing is_sequence
+
+ typedef set<int, float, double> t1;
+ typedef set<> t2;
+ typedef set<char> t3;
+
+ BOOST_MPL_ASSERT((traits::is_sequence<t1>));
+ BOOST_MPL_ASSERT((traits::is_sequence<t2>));
+ BOOST_MPL_ASSERT((traits::is_sequence<t3>));
+ }
+
+ { // testing mpl::is_sequence
+
+ typedef set<int, float, double> t1;
+ typedef set<> t2;
+ typedef set<char> t3;
+
+ BOOST_MPL_ASSERT((boost::mpl::is_sequence<t1>));
+ BOOST_MPL_ASSERT((boost::mpl::is_sequence<t2>));
+ BOOST_MPL_ASSERT((boost::mpl::is_sequence<t3>));
+ }
+
return boost::report_errors();
}
diff --git a/libs/fusion/test/sequence/size.cpp b/libs/fusion/test/sequence/size.cpp
new file mode 100644
index 000000000..8c4c5a55b
--- /dev/null
+++ b/libs/fusion/test/sequence/size.cpp
@@ -0,0 +1,103 @@
+/*=============================================================================
+ 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/config.hpp>
+#include <boost/fusion/container/vector.hpp>
+#include <boost/fusion/container/deque.hpp>
+#include <boost/fusion/container/list.hpp>
+#include <boost/fusion/container/set.hpp>
+#include <boost/fusion/container/map.hpp>
+#include <boost/fusion/support/pair.hpp>
+#include <boost/fusion/sequence/intrinsic/size.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/assert.hpp>
+
+#include <boost/array.hpp>
+#include <boost/fusion/adapted/boost_array.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/fusion/adapted/boost_tuple.hpp>
+#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \
+ !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+#include <tuple>
+#include <boost/fusion/adapted/std_tuple.hpp>
+#endif
+
+template <typename LHS, typename RHS>
+void check_(LHS const&, RHS const&)
+{
+ BOOST_MPL_ASSERT((boost::is_same<LHS, RHS>));
+}
+
+template <typename S>
+void check()
+{
+ check_(
+ boost::fusion::result_of::size<S>::type::value
+ , boost::fusion::result_of::size<S>::value
+ );
+}
+
+void test()
+{
+ {
+ check<boost::fusion::vector<> >();
+ check<boost::fusion::vector<int> >();
+ check<boost::fusion::vector<int, int> >();
+ check<boost::fusion::vector<int, int, int> >();
+ }
+
+ {
+ check<boost::fusion::deque<> >();
+ check<boost::fusion::deque<int> >();
+ check<boost::fusion::deque<int, int> >();
+ check<boost::fusion::deque<int, int, int> >();
+ }
+
+ {
+ check<boost::fusion::list<> >();
+ check<boost::fusion::list<int> >();
+ check<boost::fusion::list<int, int> >();
+ check<boost::fusion::list<int, int, int> >();
+ }
+
+ {
+ check<boost::fusion::set<> >();
+ check<boost::fusion::set<int> >();
+ check<boost::fusion::set<int, float> >();
+ check<boost::fusion::set<int, float, double> >();
+ }
+
+ {
+ check<boost::fusion::map<> >();
+ check<boost::fusion::map<boost::fusion::pair<int, int> > >();
+ check<boost::fusion::map<boost::fusion::pair<int, int> , boost::fusion::pair<float, int> > >();
+ check<boost::fusion::map<boost::fusion::pair<int, int> , boost::fusion::pair<float, int> , boost::fusion::pair<double, int> > >();
+ }
+
+ {
+ check<boost::array<int, 1> >();
+ check<boost::array<int, 2> >();
+ check<boost::array<int, 3> >();
+ }
+
+ {
+ check<boost::tuples::tuple<> >();
+ check<boost::tuples::tuple<int> >();
+ check<boost::tuples::tuple<int, int> >();
+ check<boost::tuples::tuple<int, int, int> >();
+ }
+
+#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \
+ !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+ {
+ check<std::tuple<> >();
+ check<std::tuple<int> >();
+ check<std::tuple<int, int> >();
+ check<std::tuple<int, int, int> >();
+ }
+#endif
+}
+
diff --git a/libs/fusion/test/sequence/std_tuple.cpp b/libs/fusion/test/sequence/std_tuple.cpp
new file mode 100644
index 000000000..2495fa550
--- /dev/null
+++ b/libs/fusion/test/sequence/std_tuple.cpp
@@ -0,0 +1,46 @@
+/*=============================================================================
+ 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/config.hpp>
+
+// adapted/std_tuple.hpp only supports implementations using variadic templates
+#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \
+ !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/fusion/adapted/std_tuple.hpp>
+#include <boost/fusion/sequence/convert.hpp>
+#include <boost/fusion/container/vector/vector.hpp>
+#include <boost/fusion/container/generation/make_vector.hpp>
+#include <tuple>
+#include <string>
+
+int
+main()
+{
+ using namespace boost::fusion;
+ using namespace boost;
+
+ {
+ // conversion vector to std tuple
+ std::tuple<int, std::string> t = convert<std_tuple_tag>(make_vector(123, "Hola!!!"));
+ BOOST_TEST(std::get<0>(t) == 123);
+ BOOST_TEST(std::get<1>(t) == "Hola!!!");
+ }
+
+ return boost::report_errors();
+}
+
+#else
+
+int
+main()
+{
+ return 0;
+}
+
+#endif
diff --git a/libs/fusion/test/sequence/std_tuple_iterator.cpp b/libs/fusion/test/sequence/std_tuple_iterator.cpp
index 202fb7a53..e33db3861 100644
--- a/libs/fusion/test/sequence/std_tuple_iterator.cpp
+++ b/libs/fusion/test/sequence/std_tuple_iterator.cpp
@@ -8,7 +8,8 @@
// The std_tuple_iterator adaptor only supports implementations
// using variadic templates
-#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \
+ !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/fusion/adapted/std_tuple.hpp>
diff --git a/libs/fusion/test/sequence/test_deduce_sequence.cpp b/libs/fusion/test/sequence/test_deduce_sequence.cpp
index d137cd307..d7a3b8135 100644
--- a/libs/fusion/test/sequence/test_deduce_sequence.cpp
+++ b/libs/fusion/test/sequence/test_deduce_sequence.cpp
@@ -1,3 +1,9 @@
+/*=============================================================================
+ Copyright (c) 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/mpl/vector.hpp>
#include <boost/fusion/support.hpp>
diff --git a/libs/fusion/test/sequence/tr1_tuple_auto_conv.cpp b/libs/fusion/test/sequence/tr1_tuple_auto_conv.cpp
deleted file mode 100644
index 010d4c710..000000000
--- a/libs/fusion/test/sequence/tr1_tuple_auto_conv.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#include <boost/tr1/memory.hpp>
-#include <boost/tr1/tuple.hpp>
-#include <boost/any.hpp>
-#include <iostream>
-
-namespace Core
-{
- class AutoConverter
- {
- std::tr1::shared_ptr<boost::any> t_;
-
- public:
- AutoConverter(std::tr1::shared_ptr<boost::any> const & t)
- : t_(t)
- {}
-
- template <typename C>
- operator C ()
- {
- try
- {
- boost::any & a = (*t_);
-
- return boost::any_cast<C>(a);
- }
- catch(boost::bad_any_cast & e)
- {
- std::cerr << "Internal conversion bug: "
- << "Failed to convert data holder to "
- << typeid(C).name() << "\n"
- << e.what()
- << std::endl;
-
- C c = C();
- return c;
- }
- }
- };
-
-
- inline AutoConverter Demo()
- {
- std::tr1::shared_ptr<boost::any> p_result
- (new boost::any(std::tr1::make_tuple(1, 2, 3, 4)));
- return p_result;
- }
-
-} // namespace Core
-
-
-int main()
-{
- std::tr1::tuple<int, int, int, int> test = Core::Demo();
- return 0;
-}
-
diff --git a/libs/fusion/test/sequence/tuple_hash.cpp b/libs/fusion/test/sequence/tuple_hash.cpp
new file mode 100644
index 000000000..e8f604ef5
--- /dev/null
+++ b/libs/fusion/test/sequence/tuple_hash.cpp
@@ -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/tuple/tuple.hpp>
+
+#define FUSION_SEQUENCE tuple
+#include "hash.hpp"
+
+int main()
+{
+ hash_test();
+ return boost::report_errors();
+}
diff --git a/libs/fusion/test/sequence/vector_hash.cpp b/libs/fusion/test/sequence/vector_hash.cpp
new file mode 100644
index 000000000..6b6dcd24c
--- /dev/null
+++ b/libs/fusion/test/sequence/vector_hash.cpp
@@ -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/vector/vector.hpp>
+
+#define FUSION_SEQUENCE vector
+#include "hash.hpp"
+
+int main()
+{
+ hash_test();
+ return boost::report_errors();
+}