fusion: merge of associative iterators/views and the new fold interface

[SVN r58618]
This commit is contained in:
Christopher Schmidt
2010-01-01 22:00:21 +00:00
parent b605617c4f
commit cda74605fc
379 changed files with 28481 additions and 2185 deletions

View File

@ -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

View File

@ -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

View File

@ -1,94 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
Copyright (c) 2007 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_ADAPT_ASSOC_CLASS_OCTOBER_4_2009_840PM)
#define BOOST_FUSION_ADAPT_ASSOC_CLASS_OCTOBER_4_2009_840PM
#include <boost/fusion/support/tag_of_fwd.hpp>
#include <boost/fusion/adapted/class/extension.hpp>
#include <boost/fusion/adapted/class/class_iterator.hpp>
#include <boost/fusion/adapted/class/detail/is_view_impl.hpp>
#include <boost/fusion/adapted/class/detail/is_sequence_impl.hpp>
#include <boost/fusion/adapted/class/detail/category_of_impl.hpp>
#include <boost/fusion/adapted/class/detail/begin_impl.hpp>
#include <boost/fusion/adapted/class/detail/end_impl.hpp>
#include <boost/fusion/adapted/class/detail/size_impl.hpp>
#include <boost/fusion/adapted/class/detail/at_impl.hpp>
#include <boost/fusion/adapted/class/detail/value_at_impl.hpp>
#include <boost/fusion/adapted/class/detail/has_key_impl.hpp>
#include <boost/fusion/adapted/class/detail/at_key_impl.hpp>
#include <boost/fusion/adapted/class/detail/value_at_key_impl.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/seq/for_each_i.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/mpl/int.hpp>
#include <boost/config/no_tr1/utility.hpp>
namespace boost { namespace fusion { namespace extension {
template<typename Class, typename Key>
struct class_assoc_member;
}}}
#define BOOST_FUSION_ADAPT_ASSOC_CLASS(name, bseq) \
BOOST_FUSION_ADAPT_ASSOC_CLASS_I( \
name, BOOST_PP_CAT(BOOST_FUSION_ADAPT_ASSOC_CLASS_X bseq, 0)) \
/***/
#define BOOST_FUSION_ADAPT_ASSOC_CLASS_X(x, y, z) ((x, y, z)) BOOST_FUSION_ADAPT_ASSOC_CLASS_Y
#define BOOST_FUSION_ADAPT_ASSOC_CLASS_Y(x, y, z) ((x, y, z)) BOOST_FUSION_ADAPT_ASSOC_CLASS_X
#define BOOST_FUSION_ADAPT_ASSOC_CLASS_X0
#define BOOST_FUSION_ADAPT_ASSOC_CLASS_Y0
// BOOST_FUSION_ADAPT_ASSOC_CLASS_I generates the overarching structure and uses
// SEQ_FOR_EACH_I to generate the "linear" substructures.
// Thanks to Paul Mensonides for the PP macro help
#define BOOST_FUSION_ADAPT_ASSOC_CLASS_I(name, seq) \
namespace boost { namespace fusion { namespace traits \
{ \
template <> \
struct tag_of<name> \
{ \
typedef class_tag type; \
}; \
}}} \
namespace boost { namespace fusion { namespace extension \
{ \
template <> \
struct class_size<name> : mpl::int_<BOOST_PP_SEQ_SIZE(seq)> {}; \
BOOST_PP_SEQ_FOR_EACH_I(BOOST_FUSION_ADAPT_ASSOC_CLASS_C, name, seq) \
}}} \
/***/
#define BOOST_FUSION_ADAPT_ASSOC_CLASS_C(r, name, i, xy) \
template <> \
struct class_member<name, i> \
{ \
typedef BOOST_PP_TUPLE_ELEM(3, 0, xy) type; \
static type& call(name& class_) \
{ \
return class_.BOOST_PP_TUPLE_ELEM(3, 1, xy); \
}; \
}; \
template<> \
struct class_assoc_member<name, BOOST_PP_TUPLE_ELEM(3, 2, xy)> \
{ \
typedef BOOST_PP_TUPLE_ELEM(3, 0, xy) type; \
static type& call(name& class_) \
{ \
return class_.BOOST_PP_TUPLE_ELEM(3, 1, xy); \
}; \
};
/***/
#endif

View File

@ -1,104 +0,0 @@
/*=============================================================================
Copyright (c) 2001-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)
==============================================================================*/
#if !defined(BOOST_FUSION_ADAPT_CLASS_OCTOBER_4_2009_840PM)
#define BOOST_FUSION_ADAPT_CLASS_OCTOBER_4_2009_840PM
#include <boost/fusion/support/tag_of_fwd.hpp>
#include <boost/fusion/adapted/class/extension.hpp>
#include <boost/fusion/adapted/class/class_iterator.hpp>
#include <boost/fusion/adapted/class/detail/is_view_impl.hpp>
#include <boost/fusion/adapted/class/detail/is_sequence_impl.hpp>
#include <boost/fusion/adapted/class/detail/category_of_impl.hpp>
#include <boost/fusion/adapted/class/detail/begin_impl.hpp>
#include <boost/fusion/adapted/class/detail/end_impl.hpp>
#include <boost/fusion/adapted/class/detail/size_impl.hpp>
#include <boost/fusion/adapted/class/detail/at_impl.hpp>
#include <boost/fusion/adapted/class/detail/value_at_impl.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/seq/for_each_i.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/mpl/int.hpp>
#include <boost/config/no_tr1/utility.hpp>
#define BOOST_FUSION_ADAPT_CLASS(name, bseq) \
BOOST_FUSION_ADAPT_CLASS_I( \
name, BOOST_PP_CAT(BOOST_FUSION_ADAPT_CLASS_X bseq, 0)) \
/***/
#define BOOST_FUSION_ADAPT_CLASS_X(w, x, y, z) ((w, x, y, z)) BOOST_FUSION_ADAPT_CLASS_Y
#define BOOST_FUSION_ADAPT_CLASS_Y(w, x, y, z) ((w, x, y, z)) BOOST_FUSION_ADAPT_CLASS_X
#define BOOST_FUSION_ADAPT_CLASS_X0
#define BOOST_FUSION_ADAPT_CLASS_Y0
// BOOST_FUSION_ADAPT_CLASS_I generates the overarching structure and uses
// SEQ_FOR_EACH_I to generate the "linear" substructures.
// Thanks to Paul Mensonides for the PP macro help
#define BOOST_FUSION_ADAPT_CLASS_I(name, seq) \
namespace boost { namespace fusion { namespace traits \
{ \
template <> \
struct tag_of<name> \
{ \
typedef class_tag type; \
}; \
}}} \
namespace boost { namespace fusion { namespace extension \
{ \
template <> \
struct class_size<name> : mpl::int_<BOOST_PP_SEQ_SIZE(seq)> {}; \
BOOST_PP_SEQ_FOR_EACH_I(BOOST_FUSION_ADAPT_CLASS_C, name, seq) \
}}} \
/***/
#define BOOST_FUSION_ADAPT_CLASS_C(r, name, i, xy) \
template <> \
struct class_member<name, i> \
{ \
typedef BOOST_PP_TUPLE_ELEM(4, 0, xy) type; \
typedef BOOST_PP_TUPLE_ELEM(4, 1, xy) get_type; \
struct proxy \
{ \
typedef BOOST_PP_TUPLE_ELEM(4, 0, xy) type; \
typedef BOOST_PP_TUPLE_ELEM(4, 1, xy) get_type; \
typedef \
add_reference<add_const<type>::type>::type \
cref_type; \
\
proxy(name& obj) : obj(obj) {} \
name& obj; \
\
proxy& operator=(cref_type val) \
{ \
BOOST_PP_TUPLE_ELEM(4, 3, xy); \
return *this; \
} \
\
operator get_type() \
{ \
return BOOST_PP_TUPLE_ELEM(4, 2, xy); \
} \
}; \
\
static get_type call(name const& obj) \
{ \
return BOOST_PP_TUPLE_ELEM(4, 2, xy); \
}; \
\
static proxy call(name& obj) \
{ \
return proxy(obj); \
}; \
}; \
/***/
#endif

View File

@ -1,105 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 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(FUSION_CLASS_ITERATOR_OCTOBER_4_2009_839M)
#define FUSION_CLASS_ITERATOR_OCTOBER_4_2009_839M
#include <boost/fusion/iterator/iterator_facade.hpp>
#include <boost/fusion/adapted/class/extension.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/minus.hpp>
#include <boost/config/no_tr1/utility.hpp>
namespace boost { namespace fusion
{
struct random_access_traversal_tag;
template <typename Class, int N_>
struct class_iterator
: iterator_facade<class_iterator<Class, N_>, random_access_traversal_tag>
{
BOOST_MPL_ASSERT_RELATION(N_, >=, 0);
BOOST_MPL_ASSERT_RELATION(N_, <=, extension::class_size<Class>::value);
typedef mpl::int_<N_> index;
typedef Class class_type;
class_iterator(Class& class_)
: class_(class_) {}
Class& class_;
template <typename Iterator>
struct value_of
: extension::class_member<Class, N_>
{
};
template <typename Iterator>
struct deref
{
typedef typename
mpl::if_<
is_const<Class>
, typename extension::class_member<Class, N_>::get_type
, typename extension::class_member<Class, N_>::proxy
>::type
type;
static type
call(Iterator const& iter)
{
return extension::class_member<Class, N_>::
call(iter.class_);
}
};
template <typename Iterator, typename N>
struct advance
{
typedef typename Iterator::index index;
typedef typename Iterator::class_type class_type;
typedef class_iterator<class_type, index::value + N::value> type;
static type
call(Iterator const& iter)
{
return type(iter.class_);
}
};
template <typename Iterator>
struct next : advance<Iterator, mpl::int_<1> > {};
template <typename Iterator>
struct prior : advance<Iterator, mpl::int_<-1> > {};
template <typename I1, typename I2>
struct distance : mpl::minus<typename I2::index, typename I1::index>
{
typedef typename
mpl::minus<
typename I2::index, typename I1::index
>::type
type;
static type
call(I1 const&, I2 const&)
{
return type();
}
};
};
}}
#endif

View File

@ -1,70 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 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_AT_IMPL_OCTOBER_4_2009_920PM)
#define BOOST_FUSION_AT_IMPL_OCTOBER_4_2009_920PM
#include <boost/fusion/support/detail/access.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/int.hpp>
namespace boost { namespace fusion
{
struct class_tag;
namespace extension
{
template<typename T>
struct at_impl;
template <typename Class, int N>
struct class_member;
template <typename Class>
struct class_size;
template <>
struct at_impl<class_tag>
{
template <typename Sequence, typename N>
struct apply
{
static int const n_value = N::value;
BOOST_MPL_ASSERT_RELATION(
n_value, <=, extension::class_size<Sequence>::value);
typedef typename
extension::class_member<Sequence, N::value>
element;
typedef typename
mpl::if_<
is_const<Sequence>
, typename class_member<Sequence, N::value>::get_type
, typename class_member<Sequence, N::value>::proxy
>::type
type;
static type
call(Sequence& seq)
{
return extension::
class_member<Sequence, N::value>::call(seq);
}
//~ static typename class_member<Sequence, N::value>::get_type
//~ call(Sequence const& seq)
//~ {
//~ return extension::
//~ class_member<Sequence, N::value>::call(seq);
//~ }
};
};
}
}}
#endif

View File

@ -1,54 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
Copyright (c) 2005-2007 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_AT_KEY_IMPL_OCTOBER_4_2009_920PM)
#define BOOST_FUSION_AT_KEY_IMPL_OCTOBER_4_2009_920PM
#include <boost/fusion/support/detail/access.hpp>
namespace boost { namespace fusion
{
struct class_tag;
namespace extension
{
template<typename T>
struct at_key_impl;
template <typename Class, typename Key>
struct class_assoc_member;
template <>
struct at_key_impl<class_tag>
{
template <typename Sequence, typename Key>
struct apply
{
typedef typename
extension::class_assoc_member<Sequence, Key>
element;
typedef typename
mpl::eval_if<
is_const<Sequence>
, detail::cref_result<element>
, detail::ref_result<element>
>::type
type;
static type
call(Sequence& seq)
{
return extension::
class_assoc_member<Sequence, Key>::call(seq);
}
};
};
}
}}
#endif

View File

@ -1,40 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 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_BEGIN_IMPL_OCTOBER_4_2009_920PM)
#define BOOST_FUSION_BEGIN_IMPL_OCTOBER_4_2009_920PM
#include <boost/fusion/adapted/class/class_iterator.hpp>
namespace boost { namespace fusion
{
struct class_tag;
namespace extension
{
template<typename T>
struct begin_impl;
template <>
struct begin_impl<class_tag>
{
template <typename Sequence>
struct apply
{
typedef class_iterator<Sequence, 0> type;
static type
call(Sequence& v)
{
return type(v);
}
};
};
}
}}
#endif

View File

@ -1,35 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 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_CATEGORY_OF_IMPL_OCTOBER_4_2009_919PM)
#define BOOST_FUSION_CATEGORY_OF_IMPL_OCTOBER_4_2009_919PM
#include <boost/config/no_tr1/utility.hpp>
namespace boost { namespace fusion
{
struct class_tag;
struct random_access_traversal_tag;
namespace extension
{
template<typename T>
struct category_of_impl;
template<>
struct category_of_impl<class_tag>
{
template<typename T>
struct apply
{
typedef random_access_traversal_tag type;
};
};
}
}}
#endif

View File

@ -16,6 +16,7 @@
namespace boost { namespace fusion
{
struct struct_tag;
struct fusion_sequence_tag;
namespace traits
{
@ -29,42 +30,60 @@ namespace boost { namespace fusion
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>
{
};
}
}}
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;
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

View File

@ -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

View File

@ -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 <> \

View File

@ -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 <> \

View File

@ -10,58 +10,63 @@
#include <boost/type_traits/add_const.hpp>
namespace boost { namespace fusion { namespace extension
namespace boost { namespace fusion
{
template <typename Struct, int N>
struct struct_member;
struct fusion_sequence_tag;
template <typename Struct>
struct struct_size;
template <typename Struct, int N>
struct struct_member<Struct const, N>
namespace extension
{
typedef typename
add_const<typename struct_member<Struct, N>::type>::type
type;
template <typename Struct, int N>
struct struct_member;
static type&
call(Struct const& struct_)
template <typename Struct>
struct struct_size;
template <typename Struct, int N>
struct struct_member<Struct const, N>
{
return struct_member<Struct, N>::call(
const_cast<Struct&>(struct_));
}
};
typedef typename
add_const<typename struct_member<Struct, N>::type>::type
type;
template <typename Struct>
struct struct_size<Struct const>
: struct_size<Struct>
{};
static type&
call(Struct const& struct_)
{
return struct_member<Struct, N>::call(
const_cast<Struct&>(struct_));
}
};
struct no_such_member;
template <typename Struct>
struct struct_size<Struct const>
: struct_size<Struct>
{};
template<typename Struct, typename Key>
struct struct_assoc_member
{
typedef no_such_member type;
};
struct no_such_member;
template<typename Struct, typename Key>
struct struct_assoc_member<Struct const, Key>
{
typedef typename
add_const<typename struct_assoc_member<Struct, Key>::type>::type
type;
static type&
call(Struct const& struct_)
template<typename Struct, typename Key>
struct struct_assoc_member
{
return struct_assoc_member<Struct, Key>::call(
const_cast<Struct&>(struct_));
}
};
typedef no_such_member type;
};
}}}
template<typename Struct, typename Key>
struct struct_assoc_member<Struct const, Key>
{
typedef typename
add_const<typename struct_assoc_member<Struct, Key>::type>::type
type;
static type&
call(Struct const& struct_)
{
return struct_assoc_member<Struct, Key>::call(
const_cast<Struct&>(struct_));
}
};
}
}}
#endif