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

View File

@ -34,18 +34,18 @@ namespace detail
template <typename F>
struct apply_fold_result
{
template <typename Value, typename State>
template <typename State, typename Value>
struct apply
: boost::result_of<F(Value,State)>
: boost::result_of<F(State, Value)>
{};
};
template <typename Iterator, typename State, typename F>
template <typename State, typename Iterator, typename F>
struct fold_apply
{
typedef typename result_of::deref<Iterator>::type dereferenced;
typedef typename add_reference<typename add_const<State>::type>::type lvalue_state;
typedef typename boost::result_of<F(dereferenced, lvalue_state)>::type type;
typedef typename boost::result_of<F(lvalue_state, dereferenced)>::type type;
};
template <typename First, typename Last, typename State, typename F>
@ -56,9 +56,9 @@ namespace detail
{
typedef typename
static_fold<
typename result_of::next<First>::type
typename result_of::next<First>::type
, Last
, typename fold_apply<First, State, F>::type
, typename fold_apply<State, First, F>::type
, F
>::type
type;
@ -78,15 +78,15 @@ namespace detail
typedef typename result::type type;
};
template<typename I0, typename State, typename F, int N>
template<typename State, typename I0, typename F, int N>
struct result_of_unrolled_fold;
template<int N>
struct unrolled_fold
{
template<typename I0, typename State, typename F>
static typename result_of_unrolled_fold<I0, State, F, N>::type
call(I0 const& i0, State const& state, F f)
template<typename State, typename I0, typename F>
static typename result_of_unrolled_fold<State, I0, F, N>::type
call(State const& state, I0 const& i0, F f)
{
typedef typename result_of::next<I0>::type I1;
I1 i1 = fusion::next(i0);
@ -97,54 +97,54 @@ namespace detail
typedef typename result_of::next<I3>::type I4;
I4 i4 = fusion::next(i3);
return unrolled_fold<N-4>::call(i4, f(*i3, f(*i2, f(*i1, f(*i0, state)))), f);
return unrolled_fold<N-4>::call(f(f(f(f(state, *i0), *i1), *i2), *i3), i4, f);
}
};
template<>
struct unrolled_fold<3>
{
template<typename I0, typename State, typename F>
static typename result_of_unrolled_fold<I0, State, F, 3>::type
call(I0 const& i0, State const& state, F f)
template<typename State, typename I0, typename F>
static typename result_of_unrolled_fold<State, I0, F, 3>::type
call(State const& state, I0 const& i0, F f)
{
typedef typename result_of::next<I0>::type I1;
I1 i1 = fusion::next(i0);
typedef typename result_of::next<I1>::type I2;
I2 i2 = fusion::next(i1);
return f(*i2, f(*i1, f(*i0, state)));
return f(f(f(state, *i0), *i1), *i2);
}
};
template<>
struct unrolled_fold<2>
{
template<typename I0, typename State, typename F>
static typename result_of_unrolled_fold<I0, State, F, 2>::type
call(I0 const& i0, State const& state, F f)
template<typename State, typename I0, typename F>
static typename result_of_unrolled_fold<State, I0, F, 2>::type
call(State const& state, I0 const& i0, F f)
{
typedef typename result_of::next<I0>::type I1;
I1 i1 = fusion::next(i0);
return f(*i1, f(*i0, state));
return f(f(state, *i0), *i1);
}
};
template<>
struct unrolled_fold<1>
{
template<typename I0, typename State, typename F>
static typename result_of_unrolled_fold<I0, State, F, 1>::type
call(I0 const& i0, State const& state, F f)
template<typename State, typename I0, typename F>
static typename result_of_unrolled_fold<State, I0, F, 1>::type
call(State const& state, I0 const& i0, F f)
{
return f(*i0, state);
return f(state, *i0);
}
};
template<>
struct unrolled_fold<0>
{
template<typename I0, typename State, typename F>
static State call(I0 const&, State const& state, F)
template<typename State, typename I0, typename F>
static State call(State const& state, I0 const&, F)
{
return state;
}
@ -171,53 +171,53 @@ namespace detail
return detail::linear_fold(
fusion::next(first)
, last
, f(*first, state)
, f(state, *first)
, f
, result_of::equal_to<typename result_of::next<First>::type, Last>()
);
}
template<typename I0, typename State, typename F, int N>
template<typename State, typename I0, typename F, int N>
struct result_of_unrolled_fold
{
typedef typename result_of::next<I0>::type I1;
typedef typename result_of::next<I1>::type I2;
typedef typename result_of::next<I2>::type I3;
typedef typename result_of::next<I3>::type I4;
typedef typename fold_apply<I0, State, F>::type Rest1;
typedef typename fold_apply<I1, Rest1, F>::type Rest2;
typedef typename fold_apply<I2, Rest2, F>::type Rest3;
typedef typename fold_apply<I3, Rest3, F>::type Rest4;
typedef typename fold_apply<State, I0, F>::type Rest1;
typedef typename fold_apply<Rest1, I1, F>::type Rest2;
typedef typename fold_apply<Rest2, I2, F>::type Rest3;
typedef typename fold_apply<Rest3, I3, F>::type Rest4;
typedef typename result_of_unrolled_fold<I4, Rest4, F, N-4>::type type;
typedef typename result_of_unrolled_fold<Rest4, I4, F, N-4>::type type;
};
template<typename I0, typename State, typename F>
struct result_of_unrolled_fold<I0, State, F, 3>
template<typename State, typename I0, typename F>
struct result_of_unrolled_fold<State, I0, F, 3>
{
typedef typename result_of::next<I0>::type I1;
typedef typename result_of::next<I1>::type I2;
typedef typename fold_apply<I0, State, F>::type Rest;
typedef typename fold_apply<I1, Rest, F>::type Rest2;
typedef typename fold_apply<I2, Rest2, F>::type type;
typedef typename fold_apply<State, I0, F>::type Rest;
typedef typename fold_apply<Rest, I1, F>::type Rest2;
typedef typename fold_apply<Rest2, I2, F>::type type;
};
template<typename I0, typename State, typename F>
struct result_of_unrolled_fold<I0, State, F, 2>
template<typename State, typename I0, typename F>
struct result_of_unrolled_fold<State, I0, F, 2>
{
typedef typename result_of::next<I0>::type I1;
typedef typename fold_apply<I0, State, F>::type Rest;
typedef typename fold_apply<I1, Rest, F>::type type;
typedef typename fold_apply<State, I0, F>::type Rest;
typedef typename fold_apply<Rest, I1, F>::type type;
};
template<typename I0, typename State, typename F>
struct result_of_unrolled_fold<I0, State, F, 1>
template<typename State, typename I0, typename F>
struct result_of_unrolled_fold<State, I0, F, 1>
{
typedef typename fold_apply<I0, State, F>::type type;
typedef typename fold_apply<State, I0, F>::type type;
};
template<typename I0, typename State, typename F>
struct result_of_unrolled_fold<I0, State, F, 0>
template<typename State, typename I0, typename F>
struct result_of_unrolled_fold<State, I0, F, 0>
{
typedef State type;
};
@ -231,7 +231,7 @@ namespace detail
typedef typename result_of::begin<Sequence>::type begin;
typedef typename result_of::end<Sequence>::type end;
typedef typename result_of_unrolled_fold<
begin, State, F, result_of::distance<begin, end>::type::value>::type type;
State, begin, F, result_of::distance<begin, end>::type::value>::type type;
};
template<typename Sequence, typename State, typename F>
@ -269,8 +269,8 @@ namespace detail
typedef typename result_of::begin<Sequence>::type begin;
typedef typename result_of::end<Sequence>::type end;
return unrolled_fold<result_of::distance<begin, end>::type::value>::call(
fusion::begin(seq)
, state
state
, fusion::begin(seq)
, f);
}
}}}

View File

@ -1,35 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 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(FUSION_ASSOC_FIND_09242005_1133)
#define FUSION_ASSOC_FIND_09242005_1133
#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_const.hpp>
namespace boost { namespace fusion { namespace detail
{
template <typename Sequence, typename Key>
struct assoc_find
{
typedef typename
mpl::if_<
is_const<Sequence>
, typename Sequence::template meta_find_impl_const<Key>::type
, typename Sequence::template meta_find_impl<Key>::type
>::type
type;
static type
call(Sequence& s)
{
return s.find_impl(mpl::identity<Key>());
}
};
}}}
#endif

View File

@ -1,6 +1,7 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2007 Dan Marsden
Copyright (c) 2009 Christopher Schmidt
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)
@ -13,7 +14,6 @@
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
@ -31,7 +31,7 @@ namespace detail
struct apply_filter
{
typedef typename mpl::apply1<
Pred, typename result_of::value_of<Iterator>::type>::type type;
Pred, Iterator>::type type;
BOOST_STATIC_CONSTANT(int, value = type::value);
};
@ -85,7 +85,7 @@ namespace detail
typedef typename
mpl::apply1<
Pred
, typename result_of::value_of<Shifted>::type
, Shifted
>::type
type;
BOOST_STATIC_CONSTANT(int, value = type::value);
@ -227,26 +227,6 @@ namespace detail
return choose_call(iter, typename traits::category_of<Iterator>::type());
}
};
template <typename First, typename Last, typename Pred>
struct static_seq_find_if : static_find_if<First, Last, Pred>
{
typedef typename static_find_if<First, Last, Pred>::type type;
template <typename Sequence>
static type
call(Sequence const& seq)
{
return static_find_if<First, Last, Pred>::call(fusion::begin(seq));
}
template <typename Sequence>
static type
call(Sequence& seq)
{
return static_find_if<First, Last, Pred>::call(fusion::begin(seq));
}
};
}}}
#endif

View File

@ -8,46 +8,43 @@
#define FUSION_FIND_05052005_1107
#include <boost/fusion/algorithm/query/detail/find_if.hpp>
#include <boost/fusion/algorithm/query/detail/assoc_find.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace fusion
{
struct associative_sequence_tag;
namespace result_of
{
template <
typename Sequence
, typename T
, bool is_associative_sequence = traits::is_associative<Sequence>::value >
struct find;
template <typename Sequence, typename T>
struct find<Sequence, T, false>
>
struct find
{
typedef
detail::static_seq_find_if<
detail::static_find_if<
typename result_of::begin<Sequence>::type
, typename result_of::end<Sequence>::type
, is_same<mpl::_, T>
, is_same<
typename mpl::if_<
traits::is_associative<Sequence>
, key_of<mpl::_1>
, value_of<mpl::_1>
>::type
, T
>
>
filter;
typedef typename filter::type type;
};
template <typename Sequence, typename T>
struct find<Sequence, T, true>
{
typedef detail::assoc_find<Sequence, T> filter;
typedef typename filter::type type;
};
}
template <typename T, typename Sequence>
@ -59,7 +56,7 @@ namespace boost { namespace fusion
find(Sequence& seq)
{
typedef typename result_of::find<Sequence, T>::filter filter;
return filter::call(seq);
return filter::call(fusion::begin(seq));
}
template <typename T, typename Sequence>
@ -67,7 +64,7 @@ namespace boost { namespace fusion
find(Sequence const& seq)
{
typedef typename result_of::find<Sequence const, T>::filter filter;
return filter::call(seq);
return filter::call(fusion::begin(seq));
}
}}

View File

@ -10,6 +10,10 @@
#include <boost/fusion/algorithm/query/detail/find_if.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/mpl/bind.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_const.hpp>
@ -20,13 +24,18 @@ namespace boost { namespace fusion
template <typename Sequence, typename Pred>
struct find_if
{
typedef typename
typedef
detail::static_find_if<
typename result_of::begin<Sequence>::type
, typename result_of::end<Sequence>::type
, Pred
>::type
type;
, mpl::bind1<
typename mpl::lambda<Pred>::type
, mpl::bind1<mpl::quote1<value_of>,mpl::_1>
>
>
filter;
typedef typename filter::type type;
};
}
@ -38,14 +47,7 @@ namespace boost { namespace fusion
>::type
find_if(Sequence& seq)
{
typedef
detail::static_find_if<
typename result_of::begin<Sequence>::type
, typename result_of::end<Sequence>::type
, Pred
>
filter;
typedef typename result_of::find_if<Sequence, Pred>::filter filter;
return filter::call(fusion::begin(seq));
}
@ -53,14 +55,7 @@ namespace boost { namespace fusion
inline typename result_of::find_if<Sequence const, Pred>::type const
find_if(Sequence const& seq)
{
typedef
detail::static_find_if<
typename result_of::begin<Sequence const>::type
, typename result_of::end<Sequence const>::type
, Pred
>
filter;
typedef typename result_of::find_if<Sequence const, Pred>::filter filter;
return filter::call(fusion::begin(seq));
}
}}

View File

@ -7,7 +7,7 @@
#if !defined(FUSION_ERASE_KEY_10022005_1851)
#define FUSION_ERASE_KEY_10022005_1851
#include <boost/fusion/algorithm/query/detail/assoc_find.hpp>
#include <boost/fusion/algorithm/query/find.hpp>
#include <boost/fusion/algorithm/transformation/erase.hpp>
#include <boost/mpl/not.hpp>
#include <boost/type_traits/is_same.hpp>
@ -18,18 +18,15 @@ namespace boost { namespace fusion
{
template <typename Sequence, typename Key>
struct erase_key
{
typedef detail::assoc_find<Sequence, Key> filter;
typedef typename erase<Sequence, typename filter::type>::type type;
};
: erase<Sequence, typename find<Sequence, Key>::type>
{};
}
template <typename Key, typename Sequence>
inline typename result_of::erase_key<Sequence const, Key>::type
erase_key(Sequence const& seq)
{
typedef typename result_of::erase_key<Sequence const, Key>::filter filter;
return erase(seq, filter::call(seq));
return erase(seq, find<Key>(seq));
}
}}

View File

@ -45,6 +45,7 @@ namespace boost { namespace fusion {
sequence_base<deque<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, T)> >
{
typedef deque_tag fusion_tag;
typedef bidirectional_traversal_tag category;
typedef typename detail::deque_keyed_values<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, T)>::type base;
typedef typename detail::deque_initial_size<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, T)>::type size;
typedef mpl::int_<size::value> next_up;

View File

@ -1,49 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 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(FUSION_AT_KEY_IMPL_05222005_0254)
#define FUSION_AT_KEY_IMPL_05222005_0254
#include <boost/fusion/support/detail/access.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/identity.hpp>
namespace boost { namespace fusion
{
struct map_tag;
namespace extension
{
template <typename Tag>
struct at_key_impl;
template <>
struct at_key_impl<map_tag>
{
template <typename Sequence, typename Key>
struct apply
{
typedef typename Sequence::template meta_at_impl<Key> element;
typedef typename
mpl::eval_if<
is_const<Sequence>
, detail::cref_result<element>
, detail::ref_result<element>
>::type
type;
static type
call(Sequence& m)
{
return m.at_impl(mpl::identity<Key>());
}
};
};
}
}}
#endif

View File

@ -1,56 +1,43 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#if !defined(FUSION_BEGIN_IMPL_05222005_1108)
#define FUSION_BEGIN_IMPL_05222005_1108
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_BEGIN_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_BEGIN_IMPL_HPP
namespace boost { namespace fusion
#include <boost/fusion/iterator/basic_iterator.hpp>
namespace boost { namespace fusion { namespace extension
{
struct map_tag;
template <typename>
struct begin_impl;
namespace extension
template <>
struct begin_impl<map_tag>
{
template <typename Tag>
struct begin_impl;
template <>
struct begin_impl<map_tag>
template <typename Seq>
struct apply
{
template <typename Sequence>
struct apply
typedef
basic_iterator<
map_iterator_tag
, typename Seq::category
, Seq
, 0
>
type;
static type
call(Seq& seq)
{
typedef typename
result_of::begin<typename Sequence::storage_type>::type
iterator_type;
typedef typename
result_of::begin<typename Sequence::storage_type const>::type
const_iterator_type;
typedef typename
mpl::eval_if<
is_const<Sequence>
, mpl::identity<const_iterator_type>
, mpl::identity<iterator_type>
>::type
type;
static type
call(Sequence& m)
{
return fusion::begin(m.get_data());
}
};
return type(seq,0);
}
};
}
}}
};
}}}
#endif

View File

@ -0,0 +1,48 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_DEREF_DATA_IMPL_HPP
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/support/detail/access.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_data_impl;
template <>
struct deref_data_impl<map_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename result_of::value_of<It>::type::second_type data;
typedef typename
mpl::eval_if<
is_const<typename It::seq_type>
, detail::cref_result<mpl::identity<data> >
, detail::ref_result<mpl::identity<data> >
>::type
type;
static type
call(It const& it)
{
return deref(it).second;
}
};
};
}}}
#endif

View File

@ -0,0 +1,45 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_DEREF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_DEREF_IMPL_HPP
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/type_traits/is_const.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_impl;
template <>
struct deref_impl<map_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::at<
typename mpl::if_<
is_const<typename It::seq_type>
, typename It::seq_type::storage_type const
, typename It::seq_type::storage_type
>::type
, typename It::index
>::type
type;
static type
call(It const& it)
{
return at<typename It::index>(it.seq->get_data());
}
};
};
}}}
#endif

View File

@ -1,53 +1,43 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#if !defined(FUSION_END_IMPL_05222005_1108)
#define FUSION_END_IMPL_05222005_1108
#include <boost/fusion/sequence/intrinsic/end.hpp>
#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_END_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_END_IMPL_HPP
namespace boost { namespace fusion
#include <boost/fusion/iterator/basic_iterator.hpp>
namespace boost { namespace fusion { namespace extension
{
struct map_tag;
template <typename>
struct end_impl;
namespace extension
template <>
struct end_impl<map_tag>
{
template <typename Tag>
struct end_impl;
template <>
struct end_impl<map_tag>
template <typename Seq>
struct apply
{
template <typename Sequence>
struct apply
typedef
basic_iterator<
map_iterator_tag
, typename Seq::category
, Seq
, Seq::size::value
>
type;
static type
call(Seq& seq)
{
typedef typename
result_of::end<typename Sequence::storage_type>::type
iterator_type;
typedef typename
result_of::end<typename Sequence::storage_type const>::type
const_iterator_type;
typedef typename
mpl::eval_if<
is_const<Sequence>
, mpl::identity<const_iterator_type>
, mpl::identity<iterator_type>
>::type
type;
static type
call(Sequence& m)
{
return fusion::end(m.get_data());
}
};
return type(seq,0);
}
};
}
}}
};
}}}
#endif

View File

@ -0,0 +1,32 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_KEY_OF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_KEY_OF_IMPL_HPP
#include <boost/fusion/container/map/detail/value_of_impl.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct key_of_impl;
template <>
struct key_of_impl<map_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
value_of_impl<map_iterator_tag>::
template apply<It>::type::first_type
type;
};
};
}}}
#endif

View File

@ -1,99 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 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(FUSION_LOOKUP_KEY_07222005_1248)
#define FUSION_LOOKUP_KEY_07222005_1248
#include <boost/mpl/int.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/fusion/support/detail/unknown_key.hpp>
namespace boost { namespace fusion
{
struct void_;
}}
namespace boost { namespace fusion { namespace detail
{
template <typename T>
struct map_data_type
{
typedef typename
add_reference<
typename T::second_type
>::type
type;
};
template <>
struct map_data_type<void_>
{
typedef void_& type;
};
template <typename T>
struct map_const_data_type
{
typedef typename
add_reference<
typename add_const<
typename T::second_type
>::type
>::type
type;
};
template <>
struct map_const_data_type<void_>
{
typedef void_ const& type;
};
template <typename T>
struct map_value_type
{
typedef typename T::second_type type;
};
template <>
struct map_value_type<void_>
{
typedef void_ type;
};
template <typename T, int index>
struct map_key_type
{
typedef typename T::first_type type;
};
template <int index>
struct map_key_type<void_, index>
{
typedef unknown_key<index> type;
};
template <int index, typename RT, typename Key, typename Vector>
struct map_lookup_key
{
static RT
call(Vector& vec)
{
return vec.at_impl(mpl::int_<index>()).second;
}
};
template <int index, typename Vector>
struct map_lookup_key<index, void_&, unknown_key<index>, Vector>
{
static void_&
call(Vector& vec); // intentionally undefined
};
}}}
#endif

View File

@ -1,128 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 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)
==============================================================================*/
#ifndef BOOST_PP_IS_ITERATING
#if !defined(FUSION_MAP_LOOKUP_07212005_1118)
#define FUSION_MAP_LOOKUP_07212005_1118
#include <boost/preprocessor/iterate.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1310)
#pragma warning (push)
#pragma warning(disable: 4348) // redefinition of default parameter
#endif
template <typename Key, typename dummy = int>
struct meta_at_impl
{
typedef void_ type;
};
template <typename Key, typename dummy = int>
struct meta_find_impl
{
typedef vector_iterator<storage_type, storage_type::size::value> type;
};
template <typename Key, typename dummy = int>
struct meta_find_impl_const
{
typedef vector_iterator<storage_type const, storage_type::size::value> type;
};
template <typename Key>
vector_iterator<storage_type const, storage_type::size::value>
find_impl(mpl::identity<Key>) const
{
return vector_iterator<storage_type const, storage_type::size::value>(data);
}
template <typename Key>
vector_iterator<storage_type, storage_type::size::value>
find_impl(mpl::identity<Key>)
{
return vector_iterator<storage_type, storage_type::size::value>(data);
}
#define BOOST_PP_FILENAME_1 \
<boost/fusion/container/map/detail/map_lookup.hpp>
#define BOOST_PP_ITERATION_LIMITS (0, BOOST_PP_DEC(FUSION_MAX_MAP_SIZE))
#include BOOST_PP_ITERATE()
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1310)
#pragma warning (pop)
#endif
#endif
#else // defined(BOOST_PP_IS_ITERATING)
///////////////////////////////////////////////////////////////////////////////
//
// Preprocessor vertical repetition code
//
///////////////////////////////////////////////////////////////////////////////
#define N BOOST_PP_ITERATION()
template <typename dummy>
struct meta_at_impl<
typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type, dummy>
{
typedef typename detail::map_value_type<BOOST_PP_CAT(T, N)>::type type;
};
typename detail::map_data_type<BOOST_PP_CAT(T, N)>::type
at_impl(mpl::identity<typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type>)
{
return detail::map_lookup_key<
N
, typename detail::map_data_type<BOOST_PP_CAT(T, N)>::type
, typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type
, storage_type>::call(data);
}
typename detail::map_const_data_type<BOOST_PP_CAT(T, N)>::type
at_impl(mpl::identity<typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type>) const
{
return detail::map_lookup_key<
N
, typename detail::map_const_data_type<BOOST_PP_CAT(T, N)>::type
, typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type
, storage_type const>::call(data);
}
template <typename dummy>
struct meta_find_impl<
typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type, dummy>
{
typedef vector_iterator<storage_type, N> type;
};
template <typename dummy>
struct meta_find_impl_const<
typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type, dummy>
{
typedef vector_iterator<storage_type const, N> type;
};
vector_iterator<storage_type, N>
find_impl(mpl::identity<typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type>)
{
return vector_iterator<storage_type, N>(data);
}
vector_iterator<storage_type const, N>
find_impl(mpl::identity<typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type>) const
{
return vector_iterator<storage_type const, N>(data);
}
#undef N
#endif // defined(BOOST_PP_IS_ITERATING)

View File

@ -1,33 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 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_VALUE_AT_KEY_IMPL_05222005_0325)
#define FUSION_VALUE_AT_KEY_IMPL_05222005_0325
namespace boost { namespace fusion
{
struct map_tag;
namespace extension
{
template <typename Tag>
struct value_at_key_impl;
template <>
struct value_at_key_impl<map_tag>
{
template <typename Sequence, typename Key>
struct apply
{
typedef typename Sequence::
template meta_at_impl<Key>::type type;
};
};
}
}}
#endif

View File

@ -0,0 +1,32 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_DATA_IMPL_HPP
#include <boost/fusion/container/map/detail/value_of_impl.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_data_impl;
template <>
struct value_of_data_impl<map_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
value_of_impl<map_iterator_tag>::
template apply<It>::type::second_type
type;
};
};
}}}
#endif

View File

@ -0,0 +1,39 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_IMPL_HPP
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/type_traits/is_const.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_impl;
template <>
struct value_of_impl<map_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::value_at<
typename mpl::if_<
is_const<typename It::seq_type>
, typename It::seq_type::storage_type const
, typename It::seq_type::storage_type
>::type
, typename It::index
>::type
type;
};
};
}}}
#endif

View File

@ -11,11 +11,13 @@
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/container/map/map_fwd.hpp>
#include <boost/fusion/container/map/detail/lookup_key.hpp>
#include <boost/fusion/container/map/detail/begin_impl.hpp>
#include <boost/fusion/container/map/detail/end_impl.hpp>
#include <boost/fusion/container/map/detail/at_key_impl.hpp>
#include <boost/fusion/container/map/detail/value_at_key_impl.hpp>
#include <boost/fusion/container/map/detail/value_of_impl.hpp>
#include <boost/fusion/container/map/detail/deref_data_impl.hpp>
#include <boost/fusion/container/map/detail/deref_impl.hpp>
#include <boost/fusion/container/map/detail/key_of_impl.hpp>
#include <boost/fusion/container/map/detail/value_of_data_impl.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/bool.hpp>
@ -23,13 +25,12 @@
namespace boost { namespace fusion
{
struct void_;
struct map_tag;
struct fusion_sequence_tag;
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_MAP_SIZE, typename T)>
struct map : sequence_base<map<BOOST_PP_ENUM_PARAMS(FUSION_MAX_MAP_SIZE, T)> >
{
struct category : forward_traversal_tag, associative_sequence_tag {};
struct category : forward_traversal_tag, associative_tag {};
typedef map_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
@ -49,7 +50,6 @@ namespace boost { namespace fusion
: data(rhs) {}
#include <boost/fusion/container/map/detail/map_forward_ctor.hpp>
#include <boost/fusion/container/map/detail/map_lookup.hpp>
template <typename T>
map&

View File

@ -13,6 +13,8 @@
namespace boost { namespace fusion
{
struct void_;
struct map_tag;
struct map_iterator_tag;
template <
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(

View File

@ -1,49 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 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(FUSION_AT_KEY_IMPL_09162005_1118)
#define FUSION_AT_KEY_IMPL_09162005_1118
#include <boost/fusion/support/detail/access.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/identity.hpp>
namespace boost { namespace fusion
{
struct set_tag;
namespace extension
{
template <typename Tag>
struct at_key_impl;
template <>
struct at_key_impl<set_tag>
{
template <typename Sequence, typename Key>
struct apply
{
typedef typename Sequence::template meta_at_impl<Key> element;
typedef typename
mpl::eval_if<
is_const<Sequence>
, detail::cref_result<element>
, detail::ref_result<element>
>::type
type;
static type
call(Sequence& s)
{
return s.at_impl(mpl::identity<Key>());
}
};
};
}
}}
#endif

View File

@ -1,56 +1,43 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#if !defined(FUSION_BEGIN_IMPL_09162005_1120)
#define FUSION_BEGIN_IMPL_09162005_1120
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_BEGIN_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_BEGIN_IMPL_HPP
namespace boost { namespace fusion
#include <boost/fusion/iterator/basic_iterator.hpp>
namespace boost { namespace fusion { namespace extension
{
struct set_tag;
template <typename>
struct begin_impl;
namespace extension
template <>
struct begin_impl<set_tag>
{
template <typename Tag>
struct begin_impl;
template <>
struct begin_impl<set_tag>
template <typename Seq>
struct apply
{
template <typename Sequence>
struct apply
typedef
basic_iterator<
set_iterator_tag
, typename Seq::category
, Seq
, 0
>
type;
static type
call(Seq& seq)
{
typedef typename
result_of::begin<typename Sequence::storage_type>::type
iterator_type;
typedef typename
result_of::begin<typename Sequence::storage_type const>::type
const_iterator_type;
typedef typename
mpl::eval_if<
is_const<Sequence>
, mpl::identity<const_iterator_type>
, mpl::identity<iterator_type>
>::type
type;
static type
call(Sequence& s)
{
return fusion::begin(s.get_data());
}
};
return type(seq,0);
}
};
}
}}
};
}}}
#endif

View File

@ -0,0 +1,24 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_DEREF_DATA_IMPL_HPP
#include <boost/fusion/container/set/detail/deref_impl.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_data_impl;
template <>
struct deref_data_impl<set_iterator_tag>
: deref_impl<set_iterator_tag>
{};
}}}
#endif

View File

@ -0,0 +1,45 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_DEREF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_DEREF_IMPL_HPP
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/type_traits/is_const.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_impl;
template <>
struct deref_impl<set_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::at<
typename mpl::if_<
is_const<typename It::seq_type>
, typename It::seq_type::storage_type const
, typename It::seq_type::storage_type
>::type
, typename It::index
>::type
type;
static type
call(It const& it)
{
return at<typename It::index>(it.seq->get_data());
}
};
};
}}}
#endif

View File

@ -1,53 +1,43 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#if !defined(FUSION_END_IMPL_09162005_1121)
#define FUSION_END_IMPL_09162005_1121
#include <boost/fusion/sequence/intrinsic/end.hpp>
#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_END_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_END_IMPL_HPP
namespace boost { namespace fusion
#include <boost/fusion/iterator/basic_iterator.hpp>
namespace boost { namespace fusion { namespace extension
{
struct set_tag;
template <typename>
struct end_impl;
namespace extension
template <>
struct end_impl<set_tag>
{
template <typename Tag>
struct end_impl;
template <>
struct end_impl<set_tag>
template <typename Seq>
struct apply
{
template <typename Sequence>
struct apply
typedef
basic_iterator<
set_iterator_tag
, typename Seq::category
, Seq
, Seq::size::value
>
type;
static type
call(Seq& seq)
{
typedef typename
result_of::end<typename Sequence::storage_type>::type
iterator_type;
typedef typename
result_of::end<typename Sequence::storage_type const>::type
const_iterator_type;
typedef typename
mpl::eval_if<
is_const<Sequence>
, mpl::identity<const_iterator_type>
, mpl::identity<iterator_type>
>::type
type;
static type
call(Sequence& s)
{
return fusion::end(s.get_data());
}
};
return type(seq,0);
}
};
}
}}
};
}}}
#endif

View File

@ -0,0 +1,24 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_KEY_OF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_KEY_OF_IMPL_HPP
#include <boost/fusion/container/set/detail/value_of_data_impl.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct key_of_impl;
template <>
struct key_of_impl<set_iterator_tag>
: value_of_impl<set_iterator_tag>
{};
}}}
#endif

View File

@ -1,93 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 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(FUSION_LOOKUP_KEY_09162005_1111)
#define FUSION_LOOKUP_KEY_09162005_1111
#include <boost/mpl/int.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/fusion/support/detail/unknown_key.hpp>
namespace boost { namespace fusion
{
struct void_;
}}
namespace boost { namespace fusion { namespace detail
{
template <typename T>
struct set_data_type
{
typedef typename add_reference<T>::type type;
};
template <>
struct set_data_type<void_>
{
typedef void_& type;
};
template <typename T>
struct set_const_data_type
{
typedef typename
add_reference<
typename add_const<T>::type
>::type
type;
};
template <>
struct set_const_data_type<void_>
{
typedef void_ const& type;
};
template <typename T>
struct set_value_type
{
typedef T type;
};
template <>
struct set_value_type<void_>
{
typedef void_ type;
};
template <typename T, int index>
struct set_key_type
{
typedef T type;
};
template <int index>
struct set_key_type<void_, index>
{
typedef unknown_key<index> type;
};
template <int index, typename RT, typename Key, typename Vector>
struct set_lookup_key
{
static RT
call(Vector& vec)
{
return vec.at_impl(mpl::int_<index>());
}
};
template <int index, typename Vector>
struct set_lookup_key<index, void_&, unknown_key<index>, Vector>
{
static void_&
call(Vector& vec); // intentionally undefined
};
}}}
#endif

View File

@ -1,128 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 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)
==============================================================================*/
#ifndef BOOST_PP_IS_ITERATING
#if !defined(FUSION_SET_LOOKUP_09162005_1116)
#define FUSION_SET_LOOKUP_09162005_1116
#include <boost/preprocessor/iterate.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1310)
#pragma warning (push)
#pragma warning(disable: 4348) // redefinition of default parameter
#endif
template <typename Key, typename dummy = int>
struct meta_at_impl
{
typedef void_ type;
};
template <typename Key, typename dummy = int>
struct meta_find_impl
{
typedef vector_iterator<storage_type, storage_type::size::value> type;
};
template <typename Key, typename dummy = int>
struct meta_find_impl_const
{
typedef vector_iterator<storage_type const, storage_type::size::value> type;
};
template <typename Key>
vector_iterator<storage_type const, storage_type::size::value>
find_impl(mpl::identity<Key>) const
{
return vector_iterator<storage_type const, storage_type::size::value>(data);
}
template <typename Key>
vector_iterator<storage_type, storage_type::size::value>
find_impl(mpl::identity<Key>)
{
return vector_iterator<storage_type, storage_type::size::value>(data);
}
#define BOOST_PP_FILENAME_1 \
<boost/fusion/container/set/detail/set_lookup.hpp>
#define BOOST_PP_ITERATION_LIMITS (0, BOOST_PP_DEC(FUSION_MAX_SET_SIZE))
#include BOOST_PP_ITERATE()
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1310)
#pragma warning (pop)
#endif
#endif
#else // defined(BOOST_PP_IS_ITERATING)
///////////////////////////////////////////////////////////////////////////////
//
// Preprocessor vertical repetition code
//
///////////////////////////////////////////////////////////////////////////////
#define N BOOST_PP_ITERATION()
template <typename dummy>
struct meta_at_impl<
typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type, dummy>
{
typedef typename detail::set_value_type<BOOST_PP_CAT(T, N)>::type type;
};
typename detail::set_data_type<BOOST_PP_CAT(T, N)>::type
at_impl(mpl::identity<typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type>)
{
return detail::set_lookup_key<
N
, typename detail::set_data_type<BOOST_PP_CAT(T, N)>::type
, typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type
, storage_type>::call(data);
}
typename detail::set_const_data_type<BOOST_PP_CAT(T, N)>::type
at_impl(mpl::identity<typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type>) const
{
return detail::set_lookup_key<
N
, typename detail::set_const_data_type<BOOST_PP_CAT(T, N)>::type
, typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type
, storage_type const>::call(data);
}
template <typename dummy>
struct meta_find_impl<
typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type, dummy>
{
typedef vector_iterator<storage_type, N> type;
};
template <typename dummy>
struct meta_find_impl_const<
typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type, dummy>
{
typedef vector_iterator<storage_type const, N> type;
};
vector_iterator<storage_type, N>
find_impl(mpl::identity<typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type>)
{
return vector_iterator<storage_type, N>(data);
}
vector_iterator<storage_type const, N>
find_impl(mpl::identity<typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type>) const
{
return vector_iterator<storage_type const, N>(data);
}
#undef N
#endif // defined(BOOST_PP_IS_ITERATING)

View File

@ -1,35 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 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_VALUE_AT_KEY_IMPL_09162005_1123)
#define FUSION_VALUE_AT_KEY_IMPL_09162005_1123
#include <boost/mpl/at.hpp>
namespace boost { namespace fusion
{
struct set_tag;
namespace extension
{
template <typename Tag>
struct value_at_key_impl;
template <>
struct value_at_key_impl<set_tag>
{
template <typename Sequence, typename Key>
struct apply
{
typedef typename Sequence::
template meta_at_impl<Key>::type type;
};
};
}
}}
#endif

View File

@ -0,0 +1,24 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_DATA_IMPL_HPP
#include <boost/fusion/container/set/detail/value_of_data_impl.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_data_impl;
template <>
struct value_of_data_impl<set_iterator_tag>
: value_of_impl<set_iterator_tag>
{};
}}}
#endif

View File

@ -0,0 +1,34 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_IMPL_HPP
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_impl;
template <>
struct value_of_impl<set_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::value_at<
typename It::seq_type::storage_type
, typename It::index
>::type
type;
};
};
}}}
#endif

View File

@ -11,11 +11,13 @@
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/container/set/set_fwd.hpp>
#include <boost/fusion/container/set/detail/lookup_key.hpp>
#include <boost/fusion/container/set/detail/begin_impl.hpp>
#include <boost/fusion/container/set/detail/end_impl.hpp>
#include <boost/fusion/container/set/detail/at_key_impl.hpp>
#include <boost/fusion/container/set/detail/value_at_key_impl.hpp>
#include <boost/fusion/container/set/detail/value_of_impl.hpp>
#include <boost/fusion/container/set/detail/deref_data_impl.hpp>
#include <boost/fusion/container/set/detail/deref_impl.hpp>
#include <boost/fusion/container/set/detail/key_of_impl.hpp>
#include <boost/fusion/container/set/detail/value_of_data_impl.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/bool.hpp>
@ -23,13 +25,12 @@
namespace boost { namespace fusion
{
struct void_;
struct set_tag;
struct fusion_sequence_tag;
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_SET_SIZE, typename T)>
struct set : sequence_base<set<BOOST_PP_ENUM_PARAMS(FUSION_MAX_SET_SIZE, T)> >
{
struct category : forward_traversal_tag, associative_sequence_tag {};
struct category : forward_traversal_tag, associative_tag {};
typedef set_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
@ -49,7 +50,6 @@ namespace boost { namespace fusion
: data(rhs) {}
#include <boost/fusion/container/set/detail/set_forward_ctor.hpp>
#include <boost/fusion/container/set/detail/set_lookup.hpp>
template <typename T>
set&

View File

@ -13,6 +13,8 @@
namespace boost { namespace fusion
{
struct void_;
struct set_tag;
struct set_iterator_tag;
template <
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(

View File

@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_INCLUDE_DEREF_DATA_HPP
#define BOOST_FUSION_INCLUDE_DEREF_DATA_HPP
#include <boost/fusion/iterator/deref_data.hpp>
#endif

View File

@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_INCLUDE_KEY_OF_HPP
#define BOOST_FUSION_INCLUDE_KEY_OF_HPP
#include <boost/fusion/iterator/key_of.hpp>
#endif

View File

@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_INCLUDE_VALUE_OF_DATA_HPP
#define BOOST_FUSION_INCLUDE_VALUE_OF_DATA_HPP
#include <boost/fusion/iterator/value_of_data.hpp>
#endif

View File

@ -0,0 +1,136 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_ITERATOR_BASIC_ITERATOR_HPP
#define BOOST_FUSION_ITERATOR_BASIC_ITERATOR_HPP
#include <boost/fusion/iterator/iterator_facade.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/minus.hpp>
#include <boost/mpl/int.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
namespace boost { namespace fusion
{
namespace extension
{
template <typename>
struct value_of_impl;
template <typename>
struct deref_impl;
template <typename>
struct value_of_data_impl;
template <typename>
struct key_of_impl;
template <typename>
struct deref_data_impl;
}
template<typename Tag, typename Category, typename Seq, int Index>
struct basic_iterator
: iterator_facade<basic_iterator<Tag,Category,Seq,Index>, Category>
{
typedef mpl::int_<Index> index;
typedef Seq seq_type;
template <typename It>
struct value_of
: extension::value_of_impl<Tag>::template apply<It>
{};
template <typename It>
struct deref
: extension::deref_impl<Tag>::template apply<It>
{};
template <typename It>
struct value_of_data
: extension::value_of_data_impl<Tag>::template apply<It>
{};
template <typename It>
struct key_of
: extension::key_of_impl<Tag>::template apply<It>
{};
template <typename It>
struct deref_data
: extension::deref_data_impl<Tag>::template apply<It>
{};
template <typename It, typename N>
struct advance
{
typedef
basic_iterator<Tag, Category, Seq, Index + N::value>
type;
static type
call(It const& it)
{
return type(*it.seq,0);
}
};
template <typename It>
struct next
: advance<It, mpl::int_<1> >
{};
template <typename It>
struct prior
: advance<It, mpl::int_<-1> >
{};
template <typename It1, typename It2>
struct distance
: mpl::minus<
typename It2::index
, typename It1::index
>
{};
template <typename It1, typename It2>
struct equal_to
: mpl::and_<
is_same<
typename remove_const<typename It1::seq_type>::type
, typename remove_const<typename It2::seq_type>::type
>
, mpl::equal_to<typename It1::index,typename It2::index>
>
{};
template<typename OtherSeq>
basic_iterator(basic_iterator<Tag,Category,OtherSeq,Index> const& it)
: seq(it.seq)
{}
basic_iterator(Seq& seq, int)
: seq(&seq)
{}
template<typename OtherSeq>
basic_iterator&
operator=(basic_iterator<Tag,Category,OtherSeq,Index> const& it)
{
seq=it.seq;
return *this;
}
Seq* seq;
};
}}
#endif

View File

@ -0,0 +1,49 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_ITERATOR_DEREF_DATA_HPP
#define BOOST_FUSION_ITERATOR_DEREF_DATA_HPP
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
struct iterator_facade_tag;
namespace extension
{
template <typename>
struct deref_data_impl;
template <>
struct deref_data_impl<iterator_facade_tag>
{
template <typename It>
struct apply
: It::template deref_data<It>
{};
};
}
namespace result_of
{
template <typename It>
struct deref_data
: extension::deref_data_impl<typename traits::tag_of<It>::type>::
template apply<It>
{};
}
template <typename It>
typename result_of::deref_data<It>::type
deref_data(It const& it)
{
return result_of::deref_data<It>::call(it);
}
}}
#endif

View File

@ -50,8 +50,7 @@ namespace boost { namespace fusion
template <typename First, typename Last>
struct distance :
distance_detail::linear_distance<First, Last>
{
};
{};
};
}}

View File

@ -0,0 +1,42 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_ITERATOR_KEY_OF_HPP
#define BOOST_FUSION_ITERATOR_KEY_OF_HPP
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
struct iterator_facade_tag;
namespace extension
{
template <typename>
struct key_of_impl;
template <>
struct key_of_impl<iterator_facade_tag>
{
template <typename It>
struct apply
: It::template key_of<It>
{};
};
}
namespace result_of
{
template <typename It>
struct key_of
: extension::key_of_impl<typename traits::tag_of<It>::type>::
template apply<It>
{};
}
}}
#endif

View File

@ -0,0 +1,42 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_ITERATOR_VALUE_OF_DATA_HPP
#define BOOST_FUSION_ITERATOR_VALUE_OF_DATA_HPP
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
{
struct iterator_facade_tag;
namespace extension
{
template <typename>
struct value_of_data_impl;
template <>
struct value_of_data_impl<iterator_facade_tag>
{
template <typename It>
struct apply
: It::template value_of_data<It>
{};
};
}
namespace result_of
{
template <typename It>
struct value_of_data
: extension::value_of_data_impl<typename traits::tag_of<It>::type>::
template apply<It>
{};
}
}}
#endif

View File

@ -9,6 +9,8 @@
#define BOOST_FUSION_AT_KEY_20060304_1755
#include <boost/type_traits/is_const.hpp>
#include <boost/fusion/algorithm/query/find.hpp>
#include <boost/fusion/iterator/deref_data.hpp>
#include <boost/fusion/support/tag_of.hpp>
#include <boost/fusion/support/detail/access.hpp>
@ -25,15 +27,28 @@ namespace boost { namespace fusion
template <typename Tag>
struct at_key_impl
{
template <typename Sequence, typename Key>
struct apply;
template <typename Seq, typename Key>
struct apply
{
typedef typename
result_of::deref_data<
typename result_of::find<Seq, Key>::type
>::type
type;
static type
call(Seq& seq)
{
return fusion::deref_data(fusion::find<Key>(seq));
}
};
};
template <>
struct at_key_impl<sequence_facade_tag>
{
template <typename Sequence, typename Key>
struct apply : Sequence::template at_key<Sequence, Key> {};
struct apply : Sequence::template at_key_impl<Sequence, Key> {};
};
template <>

View File

@ -28,8 +28,8 @@ namespace boost { namespace fusion
template<typename Sig>
struct result;
template<typename This, typename Seq, typename State>
struct result<This(Seq, State)>
template<typename This, typename State, typename Seq>
struct result<This(State, Seq)>
: mpl::plus<
segmented_size<typename remove_reference<Seq>::type>
, typename remove_reference<State>::type

View File

@ -7,9 +7,11 @@
#if !defined(FUSION_HAS_KEY_09232005_1454)
#define FUSION_HAS_KEY_09232005_1454
#include <boost/mpl/not.hpp>
#include <boost/fusion/support/tag_of.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/algorithm/query/find.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/mpl/not.hpp>
namespace boost { namespace fusion
{
@ -26,10 +28,14 @@ namespace boost { namespace fusion
template <typename Tag>
struct has_key_impl
{
template <typename Sequence, typename Key>
template <typename Seq, typename Key>
struct apply
: mpl::not_<is_same<typename Sequence::
template meta_at_impl<Key>::type, void_> >
: mpl::not_<
typename result_of::equal_to<
typename result_of::find<Seq, Key>::type
, typename result_of::end<Seq>::type
>::type
>::type
{};
};

View File

@ -9,6 +9,8 @@
#define FUSION_VALUE_AT_KEY_05052005_0229
#include <boost/mpl/int.hpp>
#include <boost/fusion/iterator/value_of_data.hpp>
#include <boost/fusion/algorithm/query/find.hpp>
#include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion
@ -24,8 +26,12 @@ namespace boost { namespace fusion
template <typename Tag>
struct value_at_key_impl
{
template <typename Sequence, typename Key>
struct apply;
template <typename Seq, typename Key>
struct apply
: result_of::value_of_data<
typename result_of::find<Seq, Key>::type
>
{};
};
template <>

View File

@ -33,7 +33,7 @@ namespace boost { namespace fusion
struct random_access_traversal_tag
: bidirectional_traversal_tag {};
struct associative_sequence_tag {};
struct associative_tag {};
namespace extension
{
@ -68,7 +68,7 @@ namespace boost { namespace fusion
template <typename T>
struct is_associative
: is_base_of<
associative_sequence_tag
associative_tag
, typename category_of<T>::type>
{};

View File

@ -42,8 +42,8 @@ namespace boost { namespace fusion
template<typename Sig>
struct result;
template<typename Next, typename StrictestSoFar>
struct result<strictest_traversal_impl(Next, StrictestSoFar)>
template<typename StrictestSoFar, typename Next>
struct result<strictest_traversal_impl(StrictestSoFar, Next)>
{
typedef typename remove_reference<Next>::type next_value;
typedef typename remove_reference<StrictestSoFar>::type strictest_so_far;

View File

@ -9,8 +9,10 @@
#define FUSION_SEGMENTED_ITERATOR_EAN_05032006_1027
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/next_prior.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_reference.hpp>
@ -20,6 +22,7 @@
#include <boost/fusion/view/filter_view.hpp>
#include <boost/fusion/container/list/cons.hpp> // for nil
#include <boost/fusion/container/generation/make_cons.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/distance.hpp>
#include <boost/fusion/sequence/intrinsic/ext_/segments.hpp>
#include <boost/fusion/support/ext_/is_segmented.hpp>
@ -59,16 +62,15 @@ namespace boost { namespace fusion
struct segmented_range_tag;
////////////////////////////////////////////////////////////////////////////
template<typename Sequence, typename Iterator, bool IsSegmented>
template<typename Sequence, typename Index, bool IsSegmented>
struct segmented_range
: sequence_base<segmented_range<Sequence, Iterator, IsSegmented> >
: sequence_base<segmented_range<Sequence, Index, IsSegmented> >
{
BOOST_MPL_ASSERT_NOT((is_reference<Sequence>));
typedef mpl::bool_<IsSegmented> is_segmented;
typedef segmented_range_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef mpl::true_ is_view;
typedef Iterator iterator_type;
// If this is a range of segments, skip over the empty ones
typedef typename mpl::if_<
@ -83,20 +85,34 @@ namespace boost { namespace fusion
, sequence_non_ref_type &
>::type sequence_type;
typedef
typename fusion::result_of::advance<
typename fusion::result_of::begin<sequence_non_ref_type>::type
, Index
>::type
iterator_type;
typedef typename traits::category_of<sequence_non_ref_type>::type category;
explicit segmented_range(Sequence &sequence_)
: sequence(sequence_type(sequence_))
, where_(fusion::begin(sequence))
{}
segmented_range(sequence_type sequence_, iterator_type const &wh)
segmented_range(sequence_type sequence_, int)
: sequence(sequence_)
, where_(wh)
{}
iterator_type where_() const
{
return fusion::advance<Index>(
fusion::begin(const_cast<sequence_non_ref_type &>(this->sequence))
);
}
sequence_type sequence;
iterator_type where_;
private:
segmented_range &operator =(segmented_range const &);
};
}
@ -148,7 +164,7 @@ namespace boost { namespace fusion
typedef typename Sequence::iterator_type type;
static type call(Sequence &seq)
{
return seq.where_;
return seq.where_();
}
};
};
@ -176,15 +192,15 @@ namespace boost { namespace fusion
template<typename Range>
struct range_next;
template<typename Sequence, typename Iterator, bool IsSegmented>
struct range_next<segmented_range<Sequence, Iterator, IsSegmented> >
template<typename Sequence, typename Index, bool IsSegmented>
struct range_next<segmented_range<Sequence, Index, IsSegmented> >
{
typedef typename result_of::next<Iterator>::type iterator_type;
typedef segmented_range<Sequence, iterator_type, IsSegmented> type;
typedef typename mpl::next<Index>::type index_type;
typedef segmented_range<Sequence, index_type, IsSegmented> type;
static type call(segmented_range<Sequence, Iterator, IsSegmented> const &rng)
static type call(segmented_range<Sequence, Index, IsSegmented> const &rng)
{
return type(rng.sequence, fusion::next(rng.where_));
return type(rng.sequence, 0);
}
};
@ -205,8 +221,7 @@ namespace boost { namespace fusion
{
typedef typename result_of::segments<Sequence>::type segments;
typedef typename remove_reference<segments>::type sequence;
typedef typename result_of::begin<filter_view<sequence, not_is_empty_pred> >::type begin;
typedef segmented_range<sequence, begin, true> type;
typedef segmented_range<sequence, mpl::int_<0>, true> type;
static type call(Sequence &seq)
{
@ -219,8 +234,7 @@ namespace boost { namespace fusion
struct as_segmented_range<Sequence, false>
{
typedef typename remove_reference<Sequence>::type sequence;
typedef typename result_of::begin<sequence>::type begin;
typedef segmented_range<sequence, begin, false> type;
typedef segmented_range<sequence, mpl::int_<0>, false> type;
static type call(Sequence &seq)
{
@ -228,10 +242,10 @@ namespace boost { namespace fusion
}
};
template<typename Sequence, typename Iterator, bool IsSegmented>
struct as_segmented_range<segmented_range<Sequence, Iterator, IsSegmented>, IsSegmented>
template<typename Sequence, typename Index, bool IsSegmented>
struct as_segmented_range<segmented_range<Sequence, Index, IsSegmented>, IsSegmented>
{
typedef segmented_range<Sequence, Iterator, IsSegmented> type;
typedef segmented_range<Sequence, Index, IsSegmented> type;
static type &call(type &seq)
{
return seq;

View File

@ -11,7 +11,7 @@ namespace boost { namespace fusion
{
struct filter_view_tag;
template <typename First, typename Last, typename Pred>
template <typename Category, typename First, typename Last, typename Pred>
struct filter_iterator;
namespace extension
@ -28,7 +28,8 @@ namespace boost { namespace fusion
typedef typename Sequence::first_type first_type;
typedef typename Sequence::last_type last_type;
typedef typename Sequence::pred_type pred_type;
typedef filter_iterator<first_type, last_type, pred_type> type;
typedef typename Sequence::category category;
typedef filter_iterator<category, first_type, last_type, pred_type> type;
static type
call(Sequence& s)

View File

@ -0,0 +1,37 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_DEREF_DATA_IMPL_HPP
#include <boost/fusion/iterator/deref_data.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_data_impl;
template <>
struct deref_data_impl<filter_view_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::deref_data<typename It::first_type>::type
type;
static type
call(It const& it)
{
return fusion::deref_data(it.first);
}
};
};
}}}
#endif

View File

@ -11,7 +11,7 @@ namespace boost { namespace fusion
{
struct filter_view_tag;
template <typename First, typename Last, typename Pred>
template <typename Category, typename First, typename Last, typename Pred>
struct filter_iterator;
namespace extension
@ -27,7 +27,8 @@ namespace boost { namespace fusion
{
typedef typename Sequence::last_type last_type;
typedef typename Sequence::pred_type pred_type;
typedef filter_iterator<last_type, last_type, pred_type> type;
typedef typename Sequence::category category;
typedef filter_iterator<category,last_type, last_type, pred_type> type;
static type
call(Sequence& s)

View File

@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_KEY_OF_IMPL_HPP
#define BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_KEY_OF_IMPL_HPP
#include <boost/fusion/iterator/key_of.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct key_of_impl;
template <>
struct key_of_impl<filter_view_iterator_tag>
{
template <typename It>
struct apply
: result_of::key_of<typename It::first_type>
{};
};
}}}
#endif

View File

@ -8,14 +8,19 @@
#define FUSION_NEXT_IMPL_06052005_0900
#include <boost/fusion/algorithm/query/detail/find_if.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/mpl/bind.hpp>
#include <boost/mpl/placeholders.hpp>
namespace boost { namespace fusion
{
struct filter_view_iterator_tag;
template <typename First, typename Last, typename Pred>
template <typename Category, typename First, typename Last, typename Pred>
struct filter_iterator;
namespace extension
@ -32,6 +37,7 @@ namespace boost { namespace fusion
typedef typename Iterator::first_type first_type;
typedef typename Iterator::last_type last_type;
typedef typename Iterator::pred_type pred_type;
typedef typename Iterator::category category;
typedef typename
mpl::eval_if<
@ -41,12 +47,19 @@ namespace boost { namespace fusion
>::type
next_type;
typedef typename detail::static_find_if<
next_type, last_type, pred_type>
typedef typename
detail::static_find_if<
next_type
, last_type
, mpl::bind1<
typename mpl::lambda<pred_type>::type
, mpl::bind1<mpl::quote1<result_of::value_of>,mpl::_1>
>
>
filter;
typedef filter_iterator<
typename filter::type, last_type, pred_type>
category, typename filter::type, last_type, pred_type>
type;
static type

View File

@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP
#include <boost/fusion/iterator/value_of_data.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_data_impl;
template <>
struct value_of_data_impl<filter_view_iterator_tag>
{
template <typename It>
struct apply
: result_of::value_of_data<typename It::first_type>
{};
};
}}}
#endif

View File

@ -17,6 +17,10 @@
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/inherit.hpp>
#include <boost/mpl/identity.hpp>
namespace boost { namespace fusion
{
@ -29,7 +33,13 @@ namespace boost { namespace fusion
{
typedef filter_view_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef forward_traversal_tag category;
typedef typename
mpl::eval_if<
traits::is_associative<Sequence>
, mpl::inherit2<forward_traversal_tag,associative_tag>
, mpl::identity<forward_traversal_tag>
>::type
category;
typedef mpl::true_ is_view;
typedef typename result_of::begin<Sequence>::type first_type;

View File

@ -9,20 +9,29 @@
#include <boost/fusion/iterator/mpl/convert_iterator.hpp>
#include <boost/fusion/adapted/mpl/mpl_iterator.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/support/iterator_base.hpp>
#include <boost/fusion/algorithm/query/detail/find_if.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/mpl/bind.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/fusion/view/filter_view/detail/deref_impl.hpp>
#include <boost/fusion/view/filter_view/detail/next_impl.hpp>
#include <boost/fusion/view/filter_view/detail/value_of_impl.hpp>
#include <boost/fusion/view/filter_view/detail/equal_to_impl.hpp>
#include <boost/fusion/algorithm/query/detail/find_if.hpp>
#include <boost/fusion/view/filter_view/detail/deref_data_impl.hpp>
#include <boost/fusion/view/filter_view/detail/value_of_data_impl.hpp>
#include <boost/fusion/view/filter_view/detail/key_of_impl.hpp>
namespace boost { namespace fusion
{
struct filter_view_iterator_tag;
struct forward_traversal_tag;
template <typename First, typename Last, typename Pred>
struct filter_iterator : iterator_base<filter_iterator<First, Last, Pred> >
template <typename Category, typename First, typename Last, typename Pred>
struct filter_iterator : iterator_base<filter_iterator<Category, First, Last, Pred> >
{
typedef convert_iterator<First> first_converter;
typedef typename first_converter::type first_iter;
@ -30,8 +39,17 @@ namespace boost { namespace fusion
typedef typename last_converter::type last_iter;
typedef filter_view_iterator_tag fusion_tag;
typedef forward_traversal_tag category;
typedef detail::static_find_if<first_iter, last_iter, Pred> filter;
typedef Category category;
typedef
detail::static_find_if<
first_iter
, last_iter
, mpl::bind1<
typename mpl::lambda<Pred>::type
, mpl::bind1<mpl::quote1<result_of::value_of>,mpl::_1>
>
>
filter;
typedef typename filter::type first_type;
typedef last_iter last_type;
typedef Pred pred_type;

View File

@ -17,7 +17,6 @@
#include <boost/fusion/view/iterator_range/detail/at_impl.hpp>
#include <boost/fusion/view/iterator_range/detail/value_at_impl.hpp>
#include <boost/fusion/adapted/mpl/mpl_iterator.hpp>
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion
{

View File

@ -14,7 +14,7 @@ namespace boost { namespace fusion
{
struct joint_view_tag;
template <typename First, typename Last, typename Concat>
template <typename Category, typename First, typename Last, typename Concat>
struct joint_view_iterator;
namespace extension
@ -31,13 +31,14 @@ namespace boost { namespace fusion
typedef typename Sequence::first_type first_type;
typedef typename Sequence::last_type last_type;
typedef typename Sequence::concat_type concat_type;
typedef typename Sequence::category category;
typedef result_of::equal_to<first_type, last_type> equal_to;
typedef typename
mpl::if_<
equal_to
, concat_type
, joint_view_iterator<first_type, last_type, concat_type>
, joint_view_iterator<category, first_type, last_type, concat_type>
>::type
type;

View File

@ -0,0 +1,37 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_DEREF_DATA_IMPL_HPP
#include <boost/fusion/iterator/deref_data.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_data_impl;
template <>
struct deref_data_impl<joint_view_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::deref_data<typename It::first_type>::type
type;
static type
call(It const& it)
{
return fusion::deref_data(it.first);
}
};
};
}}}
#endif

View File

@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_KEY_OF_IMPL_HPP
#define BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_KEY_OF_IMPL_HPP
#include <boost/fusion/iterator/key_of.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct key_of_impl;
template <>
struct key_of_impl<joint_view_iterator_tag>
{
template <typename It>
struct apply
: result_of::key_of<typename It::first_type>
{};
};
}}}
#endif

View File

@ -15,7 +15,7 @@ namespace boost { namespace fusion
{
struct joint_view_iterator_tag;
template <typename First, typename Last, typename Concat>
template <typename Category, typename First, typename Last, typename Concat>
struct joint_view_iterator;
namespace extension
@ -32,6 +32,7 @@ namespace boost { namespace fusion
typedef typename Iterator::first_type first_type;
typedef typename Iterator::last_type last_type;
typedef typename Iterator::concat_type concat_type;
typedef typename Iterator::category category;
typedef typename result_of::next<first_type>::type next_type;
typedef result_of::equal_to<next_type, last_type> equal_to;
@ -39,7 +40,7 @@ namespace boost { namespace fusion
mpl::if_<
equal_to
, concat_type
, joint_view_iterator<next_type, last_type, concat_type>
, joint_view_iterator<category, next_type, last_type, concat_type>
>::type
type;

View File

@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP
#include <boost/fusion/iterator/value_of_data.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_data_impl;
template <>
struct value_of_data_impl<joint_view_iterator_tag>
{
template <typename It>
struct apply
: result_of::value_of_data<typename It::first_type>
{};
};
}}}
#endif

View File

@ -19,6 +19,9 @@
#include <boost/mpl/if.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/inherit.hpp>
#include <boost/mpl/identity.hpp>
namespace boost { namespace fusion
{
@ -31,7 +34,16 @@ namespace boost { namespace fusion
{
typedef joint_view_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef forward_traversal_tag category;
typedef typename
mpl::eval_if<
mpl::and_<
traits::is_associative<Sequence1>
, traits::is_associative<Sequence2>
>
, mpl::inherit2<forward_traversal_tag,associative_tag>
, mpl::identity<forward_traversal_tag>
>::type
category;
typedef mpl::true_ is_view;
typedef typename result_of::begin<Sequence1>::type first_type;

View File

@ -14,6 +14,9 @@
#include <boost/fusion/view/joint_view/detail/deref_impl.hpp>
#include <boost/fusion/view/joint_view/detail/next_impl.hpp>
#include <boost/fusion/view/joint_view/detail/value_of_impl.hpp>
#include <boost/fusion/view/joint_view/detail/deref_data_impl.hpp>
#include <boost/fusion/view/joint_view/detail/value_of_data_impl.hpp>
#include <boost/fusion/view/joint_view/detail/key_of_impl.hpp>
#include <boost/static_assert.hpp>
namespace boost { namespace fusion
@ -21,9 +24,9 @@ namespace boost { namespace fusion
struct joint_view_iterator_tag;
struct forward_traversal_tag;
template <typename First, typename Last, typename Concat>
template <typename Category, typename First, typename Last, typename Concat>
struct joint_view_iterator
: iterator_base<joint_view_iterator<First, Last, Concat> >
: iterator_base<joint_view_iterator<Category, First, Last, Concat> >
{
typedef convert_iterator<First> first_converter;
typedef convert_iterator<Last> last_converter;
@ -34,7 +37,7 @@ namespace boost { namespace fusion
typedef typename concat_converter::type concat_type;
typedef joint_view_iterator_tag fusion_tag;
typedef forward_traversal_tag category;
typedef Category category;
BOOST_STATIC_ASSERT((!result_of::equal_to<first_type, last_type>::value));
joint_view_iterator(First const& first, Concat const& concat)

View File

@ -0,0 +1,41 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_AT_IMPL_HPP
#define BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_AT_IMPL_HPP
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/mpl/minus.hpp>
#include <boost/mpl/int.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct at_impl;
template <>
struct at_impl<reverse_view_tag>
{
template <typename Seq, typename N>
struct apply
{
typedef mpl::minus<typename Seq::size, mpl::int_<1>, N> real_n;
typedef typename
result_of::at<typename Seq::seq_type, real_n>::type
type;
static type
call(Seq& seq)
{
return fusion::at<real_n>(seq.seq);
}
};
};
}}}
#endif

View File

@ -0,0 +1,37 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_DEREF_DATA_IMPL_HPP
#include <boost/fusion/iterator/deref_data.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_data_impl;
template <>
struct deref_data_impl<reverse_view_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::deref_data<typename It::first_type>::type
type;
static type
call(It const& it)
{
return fusion::deref_data(it.first);
}
};
};
}}}
#endif

View File

@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_KEY_OF_IMPL_HPP
#define BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_KEY_OF_IMPL_HPP
#include <boost/fusion/iterator/key_of.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct key_of_impl;
template <>
struct key_of_impl<reverse_view_iterator_tag>
{
template <typename It>
struct apply
: result_of::key_of<typename It::it_type>
{};
};
}}}
#endif

View File

@ -0,0 +1,33 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_VALUE_AT_IMPL_HPP
#define BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_VALUE_AT_IMPL_HPP
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/mpl/minus.hpp>
#include <boost/mpl/int.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_at_impl;
template <>
struct value_at_impl<reverse_view_tag>
{
template <typename Seq, typename N>
struct apply
: result_of::value_at<
typename Seq::seq_type
, mpl::minus<typename Seq::size, mpl::int_<1>, N>
>
{};
};
}}}
#endif

View File

@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP
#include <boost/fusion/iterator/value_of_data.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_data_impl;
template <>
struct value_of_data_impl<reverse_view_iterator_tag>
{
template <typename It>
struct apply
: result_of::value_of_data<typename It::first_type>
{};
};
}}}
#endif

View File

@ -13,6 +13,8 @@
#include <boost/fusion/view/reverse_view/reverse_view_iterator.hpp>
#include <boost/fusion/view/reverse_view/detail/begin_impl.hpp>
#include <boost/fusion/view/reverse_view/detail/end_impl.hpp>
#include <boost/fusion/view/reverse_view/detail/at_impl.hpp>
#include <boost/fusion/view/reverse_view/detail/value_at_impl.hpp>
#include <boost/fusion/support/sequence_base.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
@ -20,6 +22,9 @@
#include <boost/type_traits/is_base_of.hpp>
#include <boost/static_assert.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/inherit.hpp>
#include <boost/mpl/identity.hpp>
namespace boost { namespace fusion
{
@ -33,6 +38,7 @@ namespace boost { namespace fusion
typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef mpl::true_ is_view;
typedef Sequence seq_type;
typedef typename traits::category_of<Sequence>::type category;
typedef typename result_of::begin<Sequence>::type first_type;
typedef typename result_of::end<Sequence>::type last_type;

View File

@ -17,6 +17,9 @@
#include <boost/fusion/view/reverse_view/detail/advance_impl.hpp>
#include <boost/fusion/view/reverse_view/detail/distance_impl.hpp>
#include <boost/fusion/view/reverse_view/detail/value_of_impl.hpp>
#include <boost/fusion/view/reverse_view/detail/deref_data_impl.hpp>
#include <boost/fusion/view/reverse_view/detail/value_of_data_impl.hpp>
#include <boost/fusion/view/reverse_view/detail/key_of_impl.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/static_assert.hpp>