mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-15 13:26:40 +02:00
Remove BOOST_PP_IS_EMPTY in favor of BOOST_MPL_PP_TOKEN_EQUAL and added auto as synonym for BOOST_FUSION_ADAPT_AUTO.
Fix ticket https://svn.boost.org/trac/boost/ticket/11157 BOOST_MPL_PP_TOKEN_EQUAL is now used to check if auto/BOOST_FUSION_ADAPT_AUTO was provided as type, telling to deduce members types.
This commit is contained in:
committed by
Kohei Takahashi
parent
1774972237
commit
2e466ac054
@ -10,12 +10,13 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
|
||||
#include <boost/fusion/adapted/adt/detail/adapt_base_attr_filler.hpp>
|
||||
|
||||
#include <boost/mpl/aux_/preprocessor/token_equal.hpp>
|
||||
|
||||
#include <boost/preprocessor/control/if.hpp>
|
||||
#include <boost/preprocessor/variadic/size.hpp>
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
#include <boost/preprocessor/facilities/is_empty.hpp>
|
||||
|
||||
#if BOOST_PP_VARIADICS
|
||||
|
||||
@ -41,7 +42,7 @@
|
||||
BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0
|
||||
|
||||
#define BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(A, B, C, D, E) \
|
||||
BOOST_PP_IF(BOOST_PP_IS_EMPTY(A), \
|
||||
BOOST_PP_IF(BOOST_MPL_PP_TOKEN_EQUAL(auto, A), \
|
||||
((3, (C,D,E))), \
|
||||
((5, (A,B,C,D,E))) \
|
||||
)
|
||||
|
@ -9,15 +9,18 @@
|
||||
#define BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
|
||||
|
||||
#include <boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp>
|
||||
|
||||
#include <boost/mpl/aux_/preprocessor/token_equal.hpp>
|
||||
|
||||
#include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
#include <boost/preprocessor/control/if.hpp>
|
||||
#include <boost/preprocessor/logical/or.hpp>
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
#include <boost/preprocessor/tuple/size.hpp>
|
||||
#include <boost/preprocessor/tuple/elem.hpp>
|
||||
#include <boost/preprocessor/facilities/is_empty.hpp>
|
||||
#include <boost/preprocessor/variadic/to_seq.hpp>
|
||||
#include <boost/preprocessor/variadic/to_tuple.hpp>
|
||||
#include <boost/preprocessor/variadic/elem.hpp>
|
||||
@ -50,8 +53,11 @@
|
||||
# define BOOST_FUSION_ADAPT_ADT_FILLER(...) \
|
||||
BOOST_PP_IF( \
|
||||
BOOST_PP_OR( \
|
||||
BOOST_PP_IS_EMPTY(BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)), \
|
||||
BOOST_PP_IS_EMPTY(BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__))), \
|
||||
BOOST_MPL_PP_TOKEN_EQUAL(auto, \
|
||||
BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)), \
|
||||
BOOST_MPL_PP_TOKEN_EQUAL(auto, \
|
||||
BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__))), \
|
||||
\
|
||||
BOOST_FUSION_ADAPT_ADT_WRAP_ATTR( \
|
||||
BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__), \
|
||||
BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(__VA_ARGS__) \
|
||||
@ -80,7 +86,7 @@
|
||||
# define BOOST_FUSION_ADAPT_ADT_FILLER_1_END
|
||||
|
||||
# define BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A, B, C, D) \
|
||||
BOOST_PP_IF(BOOST_PP_IS_EMPTY(A), \
|
||||
BOOST_PP_IF(BOOST_MPL_PP_TOKEN_EQUAL(auto, A), \
|
||||
((2, (C,D))), \
|
||||
((4, (A,B,C,D))) \
|
||||
)
|
||||
|
@ -8,8 +8,7 @@
|
||||
#ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_AUTO_HPP
|
||||
#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_AUTO_HPP
|
||||
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
|
||||
#define BOOST_FUSION_ADAPT_AUTO BOOST_PP_EMPTY()
|
||||
#define BOOST_FUSION_ADAPT_AUTO auto
|
||||
#define BOOST_MPL_PP_TOKEN_EQUAL_auto(x) x
|
||||
|
||||
#endif
|
||||
|
@ -10,13 +10,14 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
|
||||
#include <boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp>
|
||||
|
||||
#include <boost/mpl/aux_/preprocessor/token_equal.hpp>
|
||||
|
||||
#include <boost/preprocessor/control/if.hpp>
|
||||
#include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
#include <boost/preprocessor/variadic/size.hpp>
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
#include <boost/preprocessor/facilities/is_empty.hpp>
|
||||
|
||||
#if BOOST_PP_VARIADICS
|
||||
|
||||
@ -43,7 +44,7 @@
|
||||
BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0
|
||||
|
||||
#define BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(X, Y, Z) \
|
||||
BOOST_PP_IF(BOOST_PP_IS_EMPTY(X), \
|
||||
BOOST_PP_IF(BOOST_MPL_PP_TOKEN_EQUAL(auto, X), \
|
||||
((2, (Y,Z))), \
|
||||
((3, (X,Y,Z))) \
|
||||
)
|
||||
|
@ -9,12 +9,14 @@
|
||||
#define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
|
||||
#include <boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp>
|
||||
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/token_equal.hpp>
|
||||
|
||||
#include <boost/preprocessor/tuple/size.hpp>
|
||||
#include <boost/preprocessor/tuple/elem.hpp>
|
||||
#include <boost/preprocessor/facilities/is_empty.hpp>
|
||||
#include <boost/preprocessor/variadic/to_seq.hpp>
|
||||
#include <boost/preprocessor/seq/for_each.hpp>
|
||||
#include <boost/preprocessor/seq/push_front.hpp>
|
||||
@ -32,7 +34,7 @@
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_FILLER_1_END
|
||||
|
||||
#define BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR(X, Y) \
|
||||
BOOST_PP_IF(BOOST_PP_IS_EMPTY(X), \
|
||||
BOOST_PP_IF(BOOST_MPL_PP_TOKEN_EQUAL(auto, BOOST_PP_EXPAND(X)), \
|
||||
((1, (Y))), \
|
||||
((2, (X,Y))) \
|
||||
)
|
||||
@ -51,7 +53,7 @@
|
||||
BOOST_PP_CAT( BOOST_FUSION_ADAPT_STRUCT_FILLER_0 elem ,_END), \
|
||||
BOOST_PP_IF(BOOST_PP_IS_EMPTY(elem), \
|
||||
BOOST_PP_EMPTY(), \
|
||||
BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR(BOOST_FUSION_ADAPT_AUTO,elem))\
|
||||
BOOST_FUSION_ADAPT_STRUCT_WRAP_ATTR(auto,elem))\
|
||||
)
|
||||
|
||||
# define BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER(VA_ARGS_SEQ) \
|
||||
|
@ -103,7 +103,8 @@ namespace ns
|
||||
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))
|
||||
// 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))
|
||||
)
|
||||
|
||||
@ -128,23 +129,23 @@ namespace ns
|
||||
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))
|
||||
(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,
|
||||
(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))
|
||||
(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, BOOST_FUSION_ADAPT_AUTO, obj.get_first(), obj.set_first(val))
|
||||
(BOOST_FUSION_ADAPT_AUTO, auto, obj.get_first(), obj.set_first(val))
|
||||
)
|
||||
|
||||
#endif
|
||||
|
@ -72,7 +72,7 @@ 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))
|
||||
(BOOST_FUSION_ADAPT_AUTO, BOOST_FUSION_ADAPT_AUTO, obj.get_z(), obj.set_z(val))
|
||||
(auto, auto, obj.get_z(), obj.set_z(val))
|
||||
)
|
||||
|
||||
#endif // BOOST_PP_VARIADICS
|
||||
|
@ -65,7 +65,7 @@ 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)
|
||||
(auto, auto, obj.get_z(), obj.set_z(val), ns::z_member)
|
||||
)
|
||||
|
||||
#endif
|
||||
|
@ -45,12 +45,26 @@ namespace ns
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(
|
||||
#if BOOST_PP_VARIADICS
|
||||
|
||||
BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(
|
||||
ns::point,
|
||||
point,
|
||||
(int, int, obj.get_x(), obj.set_x(val), ns::x_member)
|
||||
(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,)
|
||||
|
@ -57,15 +57,15 @@ namespace ns
|
||||
BOOST_FUSION_ADAPT_ASSOC_STRUCT(
|
||||
ns::point,
|
||||
(x, ns::x_member)
|
||||
(y, ns::y_member)
|
||||
(auto, 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)
|
||||
(auto, x, ns::x_member)
|
||||
(auto, y, ns::y_member)
|
||||
(int, z, ns::z_member)
|
||||
)
|
||||
|
||||
|
@ -31,12 +31,26 @@ namespace ns
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(
|
||||
|
||||
#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)
|
||||
(int, y, ns::y_member)
|
||||
)
|
||||
(auto, y, ns::y_member)
|
||||
)
|
||||
|
||||
#endif
|
||||
|
||||
struct empty_struct {};
|
||||
BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED(empty_struct, renamed_empty_struct,);
|
||||
|
@ -66,7 +66,7 @@ BOOST_FUSION_ADAPT_ASSOC_TPL_ADT(
|
||||
(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)
|
||||
(auto, auto, obj.get_z(), obj.set_z(val), ns::z_member)
|
||||
)
|
||||
|
||||
#endif
|
||||
|
@ -55,7 +55,7 @@ namespace ns
|
||||
(X)(Y)(Z),
|
||||
(ns::point)(X)(Y)(Z),
|
||||
(int, x, ns::x_member)
|
||||
(Y, y, ns::y_member)
|
||||
(auto, y, ns::y_member)
|
||||
(z, ns::z_member)
|
||||
)
|
||||
|
||||
@ -65,7 +65,7 @@ namespace ns
|
||||
(ns::point)(X)(Y)(Z),
|
||||
(int, x, ns::x_member)
|
||||
(Y, y, ns::y_member)
|
||||
(BOOST_FUSION_ADAPT_AUTO, z, ns::z_member)
|
||||
(auto, z, ns::z_member)
|
||||
)
|
||||
#endif
|
||||
|
||||
|
@ -104,7 +104,7 @@ namespace ns
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
ns::bar,
|
||||
foo_.x, // test that adapted members can actually be expressions
|
||||
y
|
||||
(auto , y)
|
||||
)
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
@ -120,7 +120,7 @@ namespace ns
|
||||
ns::point,
|
||||
(int, x)
|
||||
(int, y)
|
||||
(BOOST_FUSION_ADAPT_AUTO, z)
|
||||
(auto, z)
|
||||
)
|
||||
|
||||
# if !BOOST_WORKAROUND(__GNUC__,<4)
|
||||
@ -128,17 +128,18 @@ namespace ns
|
||||
ns::point_with_private_attributes,
|
||||
(int, x)
|
||||
(int, y)
|
||||
(BOOST_FUSION_ADAPT_AUTO, z)
|
||||
(auto, z)
|
||||
)
|
||||
# endif
|
||||
|
||||
struct s { int m; };
|
||||
BOOST_FUSION_ADAPT_STRUCT(s, (BOOST_FUSION_ADAPT_AUTO, m))
|
||||
BOOST_FUSION_ADAPT_STRUCT(s, (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)
|
||||
(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(
|
||||
|
@ -61,13 +61,13 @@ namespace ns
|
||||
BOOST_FUSION_ADAPT_STRUCT_NAMED(
|
||||
ns::point, point,
|
||||
(int, x)
|
||||
(int, y)
|
||||
(BOOST_FUSION_ADAPT_AUTO, z)
|
||||
(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, (BOOST_FUSION_ADAPT_AUTO, m))
|
||||
BOOST_FUSION_ADAPT_STRUCT_NAMED_NS(s, (ns1), s1, (auto, m))
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -75,7 +75,7 @@ namespace ns
|
||||
(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))
|
||||
(auto, auto, obj.get_z(), obj.set_z(val))
|
||||
)
|
||||
#endif
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace ns
|
||||
(X)(Y),
|
||||
(ns::point)(X)(Y),
|
||||
x,
|
||||
(BOOST_FUSION_ADAPT_AUTO, y)
|
||||
(auto, y)
|
||||
(int, z)
|
||||
)
|
||||
|
||||
@ -60,12 +60,12 @@ namespace ns
|
||||
(ns::point)(X)(Y),
|
||||
(X, x)
|
||||
(Y, y)
|
||||
(BOOST_FUSION_ADAPT_AUTO, z)
|
||||
(auto, z)
|
||||
)
|
||||
|
||||
template<typename M>
|
||||
struct s { M m; };
|
||||
BOOST_FUSION_ADAPT_TPL_STRUCT((M), (s)(M), (BOOST_FUSION_ADAPT_AUTO, m))
|
||||
BOOST_FUSION_ADAPT_TPL_STRUCT((M), (s)(M), (auto, m))
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user