forked from boostorg/fusion
added struct wrapping facilities to make it very easy to make any struct a conforming fusion sequence
[SVN r37328]
This commit is contained in:
@ -8,7 +8,6 @@
|
|||||||
#if !defined(BOOST_FUSION_MPL_31122005_1152)
|
#if !defined(BOOST_FUSION_MPL_31122005_1152)
|
||||||
#define BOOST_FUSION_MPL_31122005_1152
|
#define BOOST_FUSION_MPL_31122005_1152
|
||||||
|
|
||||||
#include <boost/fusion/sequence/adapted/mpl/mpl_iterator.hpp>
|
|
||||||
#include <boost/fusion/sequence/adapted/mpl/detail/begin_impl.hpp>
|
#include <boost/fusion/sequence/adapted/mpl/detail/begin_impl.hpp>
|
||||||
#include <boost/fusion/sequence/adapted/mpl/detail/end_impl.hpp>
|
#include <boost/fusion/sequence/adapted/mpl/detail/end_impl.hpp>
|
||||||
#include <boost/fusion/sequence/adapted/mpl/detail/is_sequence_impl.hpp>
|
#include <boost/fusion/sequence/adapted/mpl/detail/is_sequence_impl.hpp>
|
||||||
|
@ -8,14 +8,59 @@
|
|||||||
#if !defined(BOOST_FUSION_STD_PAIR_24122005_1744)
|
#if !defined(BOOST_FUSION_STD_PAIR_24122005_1744)
|
||||||
#define BOOST_FUSION_STD_PAIR_24122005_1744
|
#define BOOST_FUSION_STD_PAIR_24122005_1744
|
||||||
|
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/tag_of.hpp>
|
#include <boost/fusion/support/tag_of_fwd.hpp>
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/detail/is_view_impl.hpp>
|
#include <boost/fusion/sequence/adapted/struct.hpp>
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/detail/is_sequence_impl.hpp>
|
#include <boost/mpl/int.hpp>
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/detail/category_of_impl.hpp>
|
#include <utility>
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/detail/begin_impl.hpp>
|
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/detail/end_impl.hpp>
|
namespace boost { namespace fusion
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/detail/size_impl.hpp>
|
{
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/detail/at_impl.hpp>
|
struct struct_tag;
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/detail/value_at_impl.hpp>
|
|
||||||
|
namespace traits
|
||||||
|
{
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
struct tag_of<std::pair<T1, T2> >
|
||||||
|
{
|
||||||
|
typedef struct_tag type;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace extension
|
||||||
|
{
|
||||||
|
template <typename Struct, int N>
|
||||||
|
struct struct_member;
|
||||||
|
|
||||||
|
template <typename Struct>
|
||||||
|
struct struct_size;
|
||||||
|
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
struct struct_member<std::pair<T1, T2>, 0>
|
||||||
|
{
|
||||||
|
typedef T1 type;
|
||||||
|
|
||||||
|
static type& call(std::pair<T1, T2>& pair)
|
||||||
|
{
|
||||||
|
return pair.first;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
struct struct_member<std::pair<T1, T2>, 1>
|
||||||
|
{
|
||||||
|
typedef T2 type;
|
||||||
|
|
||||||
|
static type& call(std::pair<T1, T2>& pair)
|
||||||
|
{
|
||||||
|
return pair.second;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
struct struct_size<std::pair<T1, T2> > : mpl::int_<2>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
/*=============================================================================
|
|
||||||
Copyright (c) 2001-2006 Joel de Guzman
|
|
||||||
Copyright (c) 2005-2006 Dan Marsden
|
|
||||||
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
==============================================================================*/
|
|
||||||
#if !defined(BOOST_FUSION_TAG_OF_24122005_1722)
|
|
||||||
#define BOOST_FUSION_TAG_OF_24122005_1722
|
|
||||||
|
|
||||||
#include <boost/fusion/support/tag_of_fwd.hpp>
|
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion {
|
|
||||||
|
|
||||||
struct std_pair_tag;
|
|
||||||
|
|
||||||
namespace traits
|
|
||||||
{
|
|
||||||
template<typename T1, typename T2>
|
|
||||||
struct tag_of<std::pair<T1, T2> >
|
|
||||||
{
|
|
||||||
typedef std_pair_tag type;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
|
|
||||||
#endif
|
|
20
include/boost/fusion/sequence/adapted/struct.hpp
Normal file
20
include/boost/fusion/sequence/adapted/struct.hpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2001-2006 Joel de Guzman
|
||||||
|
Copyright (c) 2005-2006 Dan Marsden
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
==============================================================================*/
|
||||||
|
#if !defined(BOOST_FUSION_STRUCT_24122005_1744)
|
||||||
|
#define BOOST_FUSION_STD_STRUCT_24122005_1744
|
||||||
|
|
||||||
|
#include <boost/fusion/sequence/adapted/struct/detail/is_view_impl.hpp>
|
||||||
|
#include <boost/fusion/sequence/adapted/struct/detail/is_sequence_impl.hpp>
|
||||||
|
#include <boost/fusion/sequence/adapted/struct/detail/category_of_impl.hpp>
|
||||||
|
#include <boost/fusion/sequence/adapted/struct/detail/begin_impl.hpp>
|
||||||
|
#include <boost/fusion/sequence/adapted/struct/detail/end_impl.hpp>
|
||||||
|
#include <boost/fusion/sequence/adapted/struct/detail/size_impl.hpp>
|
||||||
|
#include <boost/fusion/sequence/adapted/struct/detail/at_impl.hpp>
|
||||||
|
#include <boost/fusion/sequence/adapted/struct/detail/value_at_impl.hpp>
|
||||||
|
|
||||||
|
#endif
|
@ -8,34 +8,37 @@
|
|||||||
#if !defined(BOOST_FUSION_AT_IMPL_24122005_1807)
|
#if !defined(BOOST_FUSION_AT_IMPL_24122005_1807)
|
||||||
#define BOOST_FUSION_AT_IMPL_24122005_1807
|
#define BOOST_FUSION_AT_IMPL_24122005_1807
|
||||||
|
|
||||||
#include <boost/mpl/if.hpp>
|
|
||||||
#include <boost/mpl/int.hpp>
|
|
||||||
#include <boost/static_assert.hpp>
|
|
||||||
#include <boost/fusion/support/detail/access.hpp>
|
#include <boost/fusion/support/detail/access.hpp>
|
||||||
|
#include <boost/mpl/assert.hpp>
|
||||||
|
#include <boost/mpl/int.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion {
|
namespace boost { namespace fusion
|
||||||
|
{
|
||||||
struct std_pair_tag;
|
struct struct_tag;
|
||||||
|
|
||||||
namespace extension
|
namespace extension
|
||||||
{
|
{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct at_impl;
|
struct at_impl;
|
||||||
|
|
||||||
|
template <typename Struct, int N>
|
||||||
|
struct struct_member;
|
||||||
|
|
||||||
|
template <typename Struct>
|
||||||
|
struct struct_size;
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct at_impl<std_pair_tag>
|
struct at_impl<struct_tag>
|
||||||
{
|
{
|
||||||
template <typename Sequence, typename N>
|
template <typename Sequence, typename N>
|
||||||
struct apply
|
struct apply
|
||||||
{
|
{
|
||||||
static int const n_value = N::value;
|
static int const n_value = N::value;
|
||||||
BOOST_STATIC_ASSERT((n_value >= 0 && n_value < 2));
|
BOOST_MPL_ASSERT_RELATION(
|
||||||
|
n_value, <=, extension::struct_size<Sequence>::value);
|
||||||
|
|
||||||
typedef typename
|
typedef typename
|
||||||
mpl::if_c<
|
extension::struct_member<Sequence, N::value>
|
||||||
(n_value == 0)
|
|
||||||
, typename Sequence::first_type
|
|
||||||
, typename Sequence::second_type
|
|
||||||
>
|
|
||||||
element;
|
element;
|
||||||
|
|
||||||
typedef typename
|
typedef typename
|
||||||
@ -46,22 +49,11 @@ namespace boost { namespace fusion {
|
|||||||
>::type
|
>::type
|
||||||
type;
|
type;
|
||||||
|
|
||||||
template <typename RT>
|
|
||||||
static RT get(Sequence& p, mpl::int_<0>)
|
|
||||||
{
|
|
||||||
return p.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename RT>
|
|
||||||
static RT get(Sequence& p, mpl::int_<1>)
|
|
||||||
{
|
|
||||||
return p.second;
|
|
||||||
}
|
|
||||||
|
|
||||||
static type
|
static type
|
||||||
call(Sequence& p)
|
call(Sequence& seq)
|
||||||
{
|
{
|
||||||
return get<type>(p, N());
|
return extension::
|
||||||
|
struct_member<Sequence, N::value>::call(seq);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
@ -8,11 +8,11 @@
|
|||||||
#if !defined(BOOST_FUSION_BEGIN_IMPL_24122005_1752)
|
#if !defined(BOOST_FUSION_BEGIN_IMPL_24122005_1752)
|
||||||
#define BOOST_FUSION_BEGIN_IMPL_24122005_1752
|
#define BOOST_FUSION_BEGIN_IMPL_24122005_1752
|
||||||
|
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/std_pair_iterator.hpp>
|
#include <boost/fusion/sequence/adapted/struct/struct_iterator.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion {
|
namespace boost { namespace fusion
|
||||||
|
{
|
||||||
struct std_pair_tag;
|
struct struct_tag;
|
||||||
|
|
||||||
namespace extension
|
namespace extension
|
||||||
{
|
{
|
||||||
@ -20,12 +20,12 @@ namespace boost { namespace fusion {
|
|||||||
struct begin_impl;
|
struct begin_impl;
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct begin_impl<std_pair_tag>
|
struct begin_impl<struct_tag>
|
||||||
{
|
{
|
||||||
template <typename Sequence>
|
template <typename Sequence>
|
||||||
struct apply
|
struct apply
|
||||||
{
|
{
|
||||||
typedef std_pair_iterator<Sequence, 0> type;
|
typedef struct_iterator<Sequence, 0> type;
|
||||||
|
|
||||||
static type
|
static type
|
||||||
call(Sequence& v)
|
call(Sequence& v)
|
@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace boost { namespace fusion {
|
namespace boost { namespace fusion
|
||||||
|
{
|
||||||
struct std_pair_tag;
|
struct struct_tag;
|
||||||
struct random_access_traversal_tag;
|
struct random_access_traversal_tag;
|
||||||
|
|
||||||
namespace extension
|
namespace extension
|
||||||
@ -21,7 +21,7 @@ namespace boost { namespace fusion {
|
|||||||
struct category_of_impl;
|
struct category_of_impl;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct category_of_impl<std_pair_tag>
|
struct category_of_impl<struct_tag>
|
||||||
{
|
{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct apply
|
struct apply
|
@ -8,11 +8,11 @@
|
|||||||
#if !defined(BOOST_FUSION_END_IMPL_24122005_1755)
|
#if !defined(BOOST_FUSION_END_IMPL_24122005_1755)
|
||||||
#define BOOST_FUSION_END_IMPL_24122005_1755
|
#define BOOST_FUSION_END_IMPL_24122005_1755
|
||||||
|
|
||||||
#include <boost/fusion/sequence/adapted/std_pair/std_pair_iterator.hpp>
|
#include <boost/fusion/sequence/adapted/struct/struct_iterator.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion {
|
namespace boost { namespace fusion
|
||||||
|
{
|
||||||
struct std_pair_tag;
|
struct struct_tag;
|
||||||
|
|
||||||
namespace extension
|
namespace extension
|
||||||
{
|
{
|
||||||
@ -20,12 +20,12 @@ namespace boost { namespace fusion {
|
|||||||
struct end_impl;
|
struct end_impl;
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct end_impl<std_pair_tag>
|
struct end_impl<struct_tag>
|
||||||
{
|
{
|
||||||
template <typename Sequence>
|
template <typename Sequence>
|
||||||
struct apply
|
struct apply
|
||||||
{
|
{
|
||||||
typedef std_pair_iterator<Sequence, 2> type;
|
typedef struct_iterator<Sequence, 2> type;
|
||||||
|
|
||||||
static type
|
static type
|
||||||
call(Sequence& v)
|
call(Sequence& v)
|
@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
#include <boost/mpl/bool.hpp>
|
#include <boost/mpl/bool.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion {
|
namespace boost { namespace fusion
|
||||||
|
{
|
||||||
struct std_pair_tag;
|
struct struct_tag;
|
||||||
|
|
||||||
namespace extension
|
namespace extension
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ namespace boost { namespace fusion {
|
|||||||
struct is_sequence_impl;
|
struct is_sequence_impl;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct is_sequence_impl<std_pair_tag>
|
struct is_sequence_impl<struct_tag>
|
||||||
{
|
{
|
||||||
template<typename Sequence>
|
template<typename Sequence>
|
||||||
struct apply : mpl::true_ {};
|
struct apply : mpl::true_ {};
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
struct std_pair_tag;
|
struct struct_tag;
|
||||||
|
|
||||||
namespace extension
|
namespace extension
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ namespace boost { namespace fusion
|
|||||||
struct is_view_impl;
|
struct is_view_impl;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct is_view_impl<std_pair_tag>
|
struct is_view_impl<struct_tag>
|
||||||
{
|
{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct apply : mpl::false_
|
struct apply : mpl::false_
|
@ -10,9 +10,15 @@
|
|||||||
|
|
||||||
#include <boost/mpl/int.hpp>
|
#include <boost/mpl/int.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion {
|
namespace boost { namespace fusion
|
||||||
|
{
|
||||||
|
namespace extension
|
||||||
|
{
|
||||||
|
template <typename Struct>
|
||||||
|
struct struct_size;
|
||||||
|
}
|
||||||
|
|
||||||
struct std_pair_tag;
|
struct struct_tag;
|
||||||
|
|
||||||
namespace extension
|
namespace extension
|
||||||
{
|
{
|
||||||
@ -20,10 +26,10 @@ namespace boost { namespace fusion {
|
|||||||
struct size_impl;
|
struct size_impl;
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct size_impl<std_pair_tag>
|
struct size_impl<struct_tag>
|
||||||
{
|
{
|
||||||
template <typename Sequence>
|
template <typename Sequence>
|
||||||
struct apply : mpl::int_<2> {};
|
struct apply : extension::struct_size<Sequence> {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}}
|
}}
|
@ -11,29 +11,33 @@
|
|||||||
#include <boost/mpl/if.hpp>
|
#include <boost/mpl/if.hpp>
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion {
|
namespace boost { namespace fusion
|
||||||
|
{
|
||||||
struct std_pair_tag;
|
struct struct_tag;
|
||||||
|
|
||||||
namespace extension
|
namespace extension
|
||||||
{
|
{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct value_at_impl;
|
struct value_at_impl;
|
||||||
|
|
||||||
|
template <typename Struct, int N>
|
||||||
|
struct struct_member;
|
||||||
|
|
||||||
|
template <typename Struct>
|
||||||
|
struct struct_size;
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct value_at_impl<std_pair_tag>
|
struct value_at_impl<struct_tag>
|
||||||
{
|
{
|
||||||
template <typename Sequence, typename N>
|
template <typename Sequence, typename N>
|
||||||
struct apply
|
struct apply
|
||||||
{
|
{
|
||||||
static int const n_value = N::value;
|
static int const n_value = N::value;
|
||||||
BOOST_STATIC_ASSERT((n_value >= 0 && n_value < 2));
|
BOOST_MPL_ASSERT_RELATION(
|
||||||
|
n_value, <=, extension::struct_size<Sequence>::value);
|
||||||
|
|
||||||
typedef typename
|
typedef typename
|
||||||
mpl::if_c<
|
extension::struct_member<Sequence, N::value>::type
|
||||||
(n_value == 0)
|
|
||||||
, typename Sequence::first_type
|
|
||||||
, typename Sequence::second_type
|
|
||||||
>::type
|
|
||||||
type;
|
type;
|
||||||
};
|
};
|
||||||
};
|
};
|
@ -1,14 +1,17 @@
|
|||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
Copyright (c) 2001-2006 Joel de Guzman
|
Copyright (c) 2001-2007 Joel de Guzman
|
||||||
|
Copyright (c) 2005-2006 Dan Marsden
|
||||||
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
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)
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
#if !defined(FUSION_STD_PAIR_ITERATOR_09262005_0934)
|
#if !defined(FUSION_STRUCT_ITERATOR_APRIL_2_2007_1008AM)
|
||||||
#define FUSION_STD_PAIR_ITERATOR_09262005_0934
|
#define FUSION_STRUCT_ITERATOR_APRIL_2_2007_1008AM
|
||||||
|
|
||||||
#include <boost/fusion/iterator/iterator_facade.hpp>
|
#include <boost/fusion/iterator/iterator_facade.hpp>
|
||||||
#include <boost/type_traits/is_const.hpp>
|
#include <boost/type_traits/is_const.hpp>
|
||||||
|
#include <boost/type_traits/add_reference.hpp>
|
||||||
|
#include <boost/type_traits/add_const.hpp>
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/mpl/assert.hpp>
|
||||||
#include <boost/mpl/identity.hpp>
|
#include <boost/mpl/identity.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/mpl/if.hpp>
|
||||||
@ -18,69 +21,71 @@
|
|||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
struct random_access_traversal_tag;
|
namespace extension
|
||||||
|
|
||||||
template <typename Pair_, int N_>
|
|
||||||
struct std_pair_iterator
|
|
||||||
: iterator_facade<std_pair_iterator<Pair_, N_>, random_access_traversal_tag>
|
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT_RELATION(N_, >=, 0);
|
template <typename Struct, int N>
|
||||||
BOOST_MPL_ASSERT_RELATION(N_, <=, 2);
|
struct struct_member;
|
||||||
|
|
||||||
typedef mpl::int_<N_> index;
|
template <typename Struct>
|
||||||
typedef Pair_ pair_type;
|
struct struct_size;
|
||||||
|
|
||||||
std_pair_iterator(Pair_& pair)
|
template <typename Struct, int N>
|
||||||
: pair(pair) {}
|
struct struct_member<Struct const, N>
|
||||||
Pair_& pair;
|
|
||||||
|
|
||||||
template <typename Iterator>
|
|
||||||
struct value_of;
|
|
||||||
|
|
||||||
template <typename Pair>
|
|
||||||
struct value_of<std_pair_iterator<Pair, 0> >
|
|
||||||
: mpl::identity<typename Pair::first_type> {};
|
|
||||||
|
|
||||||
template <typename Pair>
|
|
||||||
struct value_of<std_pair_iterator<Pair, 1> >
|
|
||||||
: mpl::identity<typename Pair::second_type> {};
|
|
||||||
|
|
||||||
template <typename Iterator>
|
|
||||||
struct deref;
|
|
||||||
|
|
||||||
template <typename Pair>
|
|
||||||
struct deref<std_pair_iterator<Pair, 0> >
|
|
||||||
{
|
{
|
||||||
typedef typename
|
typedef typename
|
||||||
mpl::if_<
|
add_const<typename struct_member<Struct, N>::type>::type
|
||||||
is_const<Pair>
|
|
||||||
, typename Pair::first_type const&
|
|
||||||
, typename Pair::first_type&
|
|
||||||
>::type
|
|
||||||
type;
|
type;
|
||||||
|
|
||||||
static type
|
static type&
|
||||||
call(std_pair_iterator<Pair, 0> const& iter)
|
call(Struct const& struct_)
|
||||||
{
|
{
|
||||||
return iter.pair.first;
|
return struct_member<Struct, N>::call(
|
||||||
|
const_cast<Struct&>(struct_));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Pair>
|
template <typename Struct>
|
||||||
struct deref<std_pair_iterator<Pair, 1> >
|
struct struct_size<Struct const>
|
||||||
|
: struct_size<Struct>
|
||||||
|
{};
|
||||||
|
}
|
||||||
|
|
||||||
|
struct random_access_traversal_tag;
|
||||||
|
|
||||||
|
template <typename Struct, int N_>
|
||||||
|
struct struct_iterator
|
||||||
|
: iterator_facade<struct_iterator<Struct, N_>, random_access_traversal_tag>
|
||||||
|
{
|
||||||
|
BOOST_MPL_ASSERT_RELATION(N_, >=, 0);
|
||||||
|
BOOST_MPL_ASSERT_RELATION(N_, <=, extension::struct_size<Struct>::value);
|
||||||
|
|
||||||
|
typedef mpl::int_<N_> index;
|
||||||
|
typedef Struct struct_type;
|
||||||
|
|
||||||
|
struct_iterator(Struct& struct_)
|
||||||
|
: struct_(struct_) {}
|
||||||
|
Struct& struct_;
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
struct value_of
|
||||||
|
: extension::struct_member<Struct, N_>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
struct deref
|
||||||
{
|
{
|
||||||
typedef typename
|
typedef typename
|
||||||
mpl::if_<
|
add_reference<
|
||||||
is_const<Pair>
|
typename extension::struct_member<Struct, N_>::type
|
||||||
, typename Pair::second_type const&
|
|
||||||
, typename Pair::second_type&
|
|
||||||
>::type
|
>::type
|
||||||
type;
|
type;
|
||||||
|
|
||||||
static type
|
static type
|
||||||
call(std_pair_iterator<Pair, 1> const& iter)
|
call(Iterator const& iter)
|
||||||
{
|
{
|
||||||
return iter.pair.second;
|
return extension::struct_member<Struct, N_>::
|
||||||
|
call(iter.struct_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -88,13 +93,13 @@ namespace boost { namespace fusion
|
|||||||
struct advance
|
struct advance
|
||||||
{
|
{
|
||||||
typedef typename Iterator::index index;
|
typedef typename Iterator::index index;
|
||||||
typedef typename Iterator::pair_type pair_type;
|
typedef typename Iterator::struct_type struct_type;
|
||||||
typedef std_pair_iterator<pair_type, index::value + N::value> type;
|
typedef struct_iterator<struct_type, index::value + N::value> type;
|
||||||
|
|
||||||
static type
|
static type
|
||||||
call(Iterator const& iter)
|
call(Iterator const& iter)
|
||||||
{
|
{
|
||||||
return type(iter.pair);
|
return type(iter.struct_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Reference in New Issue
Block a user