mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-23 09:07:26 +02:00
Fusion: merge from trunk
[SVN r65735]
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
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/class/adapt_class.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>
|
||||
@ -28,6 +28,7 @@
|
||||
#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>
|
||||
|
||||
@ -50,14 +51,42 @@ namespace ns
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
#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) {}
|
||||
point_with_private_members(int x, int y) : x(x), y(y) {}
|
||||
|
||||
private:
|
||||
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_; }
|
||||
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_CLASS(
|
||||
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_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
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
@ -124,6 +153,51 @@ main()
|
||||
, mpl::front<ns::point>::type>));
|
||||
}
|
||||
|
||||
#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);
|
||||
|
||||
std::cout << at_c<0>(p) << std::endl;
|
||||
std::cout << at_c<1>(p) << std::endl;
|
||||
std::cout << p << std::endl;
|
||||
BOOST_TEST(p == make_vector(123, 456));
|
||||
|
||||
at_c<0>(p) = 6;
|
||||
at_c<1>(p) = 9;
|
||||
BOOST_TEST(p == make_vector(6, 9));
|
||||
|
||||
BOOST_STATIC_ASSERT(result_of::size<ns::point_with_private_members>::value == 2);
|
||||
BOOST_STATIC_ASSERT(!result_of::empty<ns::point_with_private_members>::value);
|
||||
|
||||
BOOST_TEST(front(p) == 6);
|
||||
BOOST_TEST(back(p) == 9);
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<
|
||||
result_of::front<ns::point>::type,
|
||||
boost::fusion::extension::adt_attribute_proxy<ns::point,0,false>
|
||||
>));
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<
|
||||
result_of::front<ns::point>::type::type,
|
||||
int
|
||||
>));
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<
|
||||
result_of::front<ns::point const>::type,
|
||||
boost::fusion::extension::adt_attribute_proxy<ns::point,0,true>
|
||||
>));
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<
|
||||
result_of::front<ns::point const>::type::type,
|
||||
int
|
||||
>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
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/class/adapt_class_named.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>
|
||||
@ -53,7 +53,7 @@ namespace ns
|
||||
}
|
||||
|
||||
// this creates a fusion view: boost::fusion::adapted::point
|
||||
BOOST_FUSION_ADAPT_CLASS_NAMED(
|
||||
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))
|
@ -10,7 +10,7 @@
|
||||
#include <boost/fusion/container/list.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/adapted/class/adapt_assoc_class.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>
|
||||
@ -45,7 +45,7 @@ namespace ns
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_ASSOC_CLASS(
|
||||
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)
|
@ -10,7 +10,7 @@
|
||||
#include <boost/fusion/container/list.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/adapted/class/adapt_assoc_class_named.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>
|
||||
@ -45,7 +45,7 @@ namespace ns
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_ASSOC_CLASS_NAMED(
|
||||
BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(
|
||||
ns::point,
|
||||
point,
|
||||
(int, int, obj.obj.get_x(), obj.obj.set_x(val), ns::x_member)
|
@ -10,7 +10,7 @@
|
||||
#include <boost/fusion/container/list.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/adapted/class/adapt_assoc_class.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>
|
||||
@ -46,7 +46,7 @@ namespace ns
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_ASSOC_TPL_CLASS(
|
||||
BOOST_FUSION_ADAPT_ASSOC_TPL_ADT(
|
||||
(X)(Y),
|
||||
(ns::point)(X)(Y),
|
||||
(X, X, obj.get_x(), obj.set_x(val), ns::x_member)
|
@ -28,6 +28,7 @@
|
||||
#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>
|
||||
|
||||
@ -38,6 +39,21 @@ namespace ns
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
#if !BOOST_WORKAROUND(__GNUC__,<4)
|
||||
struct point_with_private_attributes
|
||||
{
|
||||
friend struct boost::fusion::extension::access;
|
||||
|
||||
private:
|
||||
int x;
|
||||
int y;
|
||||
|
||||
public:
|
||||
point_with_private_attributes(int x, int y):x(x),y(y)
|
||||
{}
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
@ -46,6 +62,14 @@ BOOST_FUSION_ADAPT_STRUCT(
|
||||
(int, 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))
|
||||
|
||||
@ -118,7 +142,6 @@ main()
|
||||
BOOST_MPL_ASSERT((is_same<result_of::next<b>::type, e>));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<ns::point>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<
|
||||
@ -126,6 +149,17 @@ main()
|
||||
, mpl::front<ns::point>::type>));
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(__GNUC__,<4)
|
||||
{
|
||||
ns::point_with_private_attributes 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));
|
||||
}
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
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/class/adapt_class.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>
|
||||
@ -54,7 +54,7 @@ namespace ns
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_TPL_CLASS(
|
||||
BOOST_FUSION_ADAPT_TPL_ADT(
|
||||
(X)(Y),
|
||||
(ns::point)(X)(Y),
|
||||
(X, X, obj.get_x(), obj.set_x(val))
|
Reference in New Issue
Block a user