mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-14 12:56:38 +02:00
mpl::sequence_tag specialization for adapted types
[SVN r58396]
This commit is contained in:
@ -21,6 +21,7 @@ namespace boost
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct array_tag;
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
namespace traits
|
||||
{
|
||||
@ -36,4 +37,22 @@ namespace boost { namespace fusion
|
||||
}
|
||||
}}
|
||||
|
||||
namespace boost { namespace mpl
|
||||
{
|
||||
template<typename>
|
||||
struct sequence_tag;
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
struct sequence_tag<array<T,N> >
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
struct sequence_tag<array<T,N> const>
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
@ -26,6 +26,7 @@ namespace boost { namespace tuples
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct boost_tuple_tag;
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
namespace traits
|
||||
{
|
||||
@ -60,4 +61,54 @@ namespace boost { namespace fusion
|
||||
}
|
||||
}}
|
||||
|
||||
namespace boost { namespace mpl
|
||||
{
|
||||
template<typename>
|
||||
struct sequence_tag;
|
||||
|
||||
template <
|
||||
class T0, class T1, class T2, class T3, class T4,
|
||||
class T5, class T6, class T7, class T8, class T9
|
||||
>
|
||||
struct sequence_tag<tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
|
||||
template <
|
||||
class T0, class T1, class T2, class T3, class T4,
|
||||
class T5, class T6, class T7, class T8, class T9
|
||||
>
|
||||
struct sequence_tag<
|
||||
tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> const
|
||||
>
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct sequence_tag<tuples::cons<Head, Tail> >
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct sequence_tag<tuples::cons<Head, Tail> const>
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct sequence_tag<tuples::null_type>
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct sequence_tag<tuples::null_type const>
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
@ -62,6 +62,25 @@ namespace boost { namespace fusion { namespace extension {
|
||||
typedef class_tag type; \
|
||||
}; \
|
||||
}}} \
|
||||
\
|
||||
namespace boost { namespace mpl \
|
||||
{ \
|
||||
template<typename> \
|
||||
struct sequence_tag; \
|
||||
\
|
||||
template<> \
|
||||
struct sequence_tag<name> \
|
||||
{ \
|
||||
typedef fusion::fusion_sequence_tag type; \
|
||||
}; \
|
||||
\
|
||||
template<> \
|
||||
struct sequence_tag<name const> \
|
||||
{ \
|
||||
typedef fusion::fusion_sequence_tag type; \
|
||||
}; \
|
||||
}} \
|
||||
\
|
||||
namespace boost { namespace fusion { namespace extension \
|
||||
{ \
|
||||
template <> \
|
||||
|
@ -52,6 +52,25 @@
|
||||
typedef class_tag type; \
|
||||
}; \
|
||||
}}} \
|
||||
\
|
||||
namespace boost { namespace mpl \
|
||||
{ \
|
||||
template<typename> \
|
||||
struct sequence_tag; \
|
||||
\
|
||||
template<> \
|
||||
struct sequence_tag<name> \
|
||||
{ \
|
||||
typedef fusion::fusion_sequence_tag type; \
|
||||
}; \
|
||||
\
|
||||
template<> \
|
||||
struct sequence_tag<name const> \
|
||||
{ \
|
||||
typedef fusion::fusion_sequence_tag type; \
|
||||
}; \
|
||||
}} \
|
||||
\
|
||||
namespace boost { namespace fusion { namespace extension \
|
||||
{ \
|
||||
template <> \
|
||||
|
@ -10,7 +10,11 @@
|
||||
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace extension
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Class, int N>
|
||||
struct class_member;
|
||||
@ -49,7 +53,8 @@ namespace boost { namespace fusion { namespace extension
|
||||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct struct_tag;
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
namespace traits
|
||||
{
|
||||
@ -29,8 +30,27 @@ namespace boost { namespace fusion
|
||||
typedef struct_tag type;
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
namespace extension
|
||||
namespace boost { namespace mpl
|
||||
{
|
||||
template<typename>
|
||||
struct sequence_tag;
|
||||
|
||||
template<typename T1, typename T2>
|
||||
struct sequence_tag<std::pair<T1, T2> >
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
|
||||
template<typename T1, typename T2>
|
||||
struct sequence_tag<std::pair<T1, T2> const>
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
}}
|
||||
|
||||
namespace boost { namespace fusion { namespace extension
|
||||
{
|
||||
template <typename Struct, int N>
|
||||
struct struct_member;
|
||||
@ -64,7 +84,6 @@ namespace boost { namespace fusion
|
||||
struct struct_size<std::pair<T1, T2> > : mpl::int_<2>
|
||||
{
|
||||
};
|
||||
}
|
||||
}}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
@ -15,6 +15,7 @@
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct std_pair_tag;
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
namespace traits
|
||||
{
|
||||
@ -26,4 +27,22 @@ namespace boost { namespace fusion {
|
||||
}
|
||||
}}
|
||||
|
||||
namespace boost { namespace mpl
|
||||
{
|
||||
template<typename>
|
||||
struct sequence_tag;
|
||||
|
||||
template<typename T1, typename T2>
|
||||
struct sequence_tag<std::pair<T1, T2> >
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
|
||||
template<typename T1, typename T2>
|
||||
struct sequence_tag<std::pair<T1, T2> const>
|
||||
{
|
||||
typedef fusion::fusion_sequence_tag type;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
@ -62,6 +62,25 @@ namespace boost { namespace fusion { namespace extension {
|
||||
typedef struct_tag type; \
|
||||
}; \
|
||||
}}} \
|
||||
\
|
||||
namespace boost { namespace mpl \
|
||||
{ \
|
||||
template<typename> \
|
||||
struct sequence_tag; \
|
||||
\
|
||||
template<> \
|
||||
struct sequence_tag<name> \
|
||||
{ \
|
||||
typedef fusion::fusion_sequence_tag type; \
|
||||
}; \
|
||||
\
|
||||
template<> \
|
||||
struct sequence_tag<name const> \
|
||||
{ \
|
||||
typedef fusion::fusion_sequence_tag type; \
|
||||
}; \
|
||||
}} \
|
||||
\
|
||||
namespace boost { namespace fusion { namespace extension \
|
||||
{ \
|
||||
template <> \
|
||||
|
@ -52,6 +52,25 @@
|
||||
typedef struct_tag type; \
|
||||
}; \
|
||||
}}} \
|
||||
\
|
||||
namespace boost { namespace mpl \
|
||||
{ \
|
||||
template<typename> \
|
||||
struct sequence_tag; \
|
||||
\
|
||||
template<> \
|
||||
struct sequence_tag<name> \
|
||||
{ \
|
||||
typedef fusion::fusion_sequence_tag type; \
|
||||
}; \
|
||||
\
|
||||
template<> \
|
||||
struct sequence_tag<name const> \
|
||||
{ \
|
||||
typedef fusion::fusion_sequence_tag type; \
|
||||
}; \
|
||||
}} \
|
||||
\
|
||||
namespace boost { namespace fusion { namespace extension \
|
||||
{ \
|
||||
template <> \
|
||||
|
@ -10,7 +10,11 @@
|
||||
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace extension
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Struct, int N>
|
||||
struct struct_member;
|
||||
@ -61,7 +65,8 @@ namespace boost { namespace fusion { namespace extension
|
||||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <boost/fusion/sequence/intrinsic/back.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
@ -26,7 +27,10 @@
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
@ -126,6 +130,13 @@ main()
|
||||
BOOST_TEST(at_key<ns::y_member>(p) == 3);
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<ns::point>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<
|
||||
fusion::result_of::value_at_c<ns::point,0>::type
|
||||
, mpl::front<ns::point>::type>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/front.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/back.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
@ -22,7 +23,10 @@
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -113,6 +117,13 @@ main()
|
||||
l = p;
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<ns::point>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<
|
||||
fusion::result_of::value_at_c<ns::point,0>::type
|
||||
, mpl::front<ns::point>::type>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/front.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/back.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
@ -22,7 +23,10 @@
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -114,6 +118,14 @@ 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<
|
||||
fusion::result_of::value_at_c<ns::point,0>::type
|
||||
, mpl::front<ns::point>::type>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,12 @@
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/fusion/iterator.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -37,5 +41,8 @@ int main()
|
||||
BOOST_TEST(size(arr) == 3);
|
||||
BOOST_TEST(distance(begin(arr), end(arr)) == 3);
|
||||
|
||||
BOOST_MPL_ASSERT((boost::mpl::is_sequence<array_type>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<int, boost::mpl::front<array_type>::type>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -23,8 +23,11 @@
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -96,6 +99,12 @@ main()
|
||||
BOOST_TEST(2u == fusion::distance(fusion::begin(t), fusion::end(t)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::tuple<int, std::string> tuple_type;
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<tuple_type>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<int, mpl::front<tuple_type>::type>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,10 @@
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -86,6 +89,12 @@ main()
|
||||
l = std::make_pair(123, "Hola!!!");
|
||||
}
|
||||
|
||||
{
|
||||
typedef std::pair<int, std::string> pair_type;
|
||||
BOOST_MPL_ASSERT((mpl::is_sequence<pair_type>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<int, mpl::front<pair_type>::type>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user