associative iterators & views

[SVN r57156]
This commit is contained in:
Christopher Schmidt
2009-10-25 22:59:54 +00:00
parent 35e469e2d5
commit 9b26b4a0f7
69 changed files with 1331 additions and 942 deletions

View File

@ -56,7 +56,7 @@ namespace detail
{ {
typedef typename typedef typename
static_fold< static_fold<
typename result_of::next<First>::type typename result_of::next<First>::type
, Last , Last
, typename fold_apply<State, First, F>::type , typename fold_apply<State, First, F>::type
, F , 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) 2001-2006 Joel de Guzman
Copyright (c) 2007 Dan Marsden Copyright (c) 2007 Dan Marsden
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) 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/lambda.hpp>
#include <boost/mpl/apply.hpp> #include <boost/mpl/apply.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/iterator/equal_to.hpp> #include <boost/fusion/iterator/equal_to.hpp>
#include <boost/fusion/iterator/next.hpp> #include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp>
@ -31,7 +31,7 @@ namespace detail
struct apply_filter struct apply_filter
{ {
typedef typename mpl::apply1< 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); BOOST_STATIC_CONSTANT(int, value = type::value);
}; };
@ -85,7 +85,7 @@ namespace detail
typedef typename typedef typename
mpl::apply1< mpl::apply1<
Pred Pred
, typename result_of::value_of<Shifted>::type , Shifted
>::type >::type
type; type;
BOOST_STATIC_CONSTANT(int, value = type::value); BOOST_STATIC_CONSTANT(int, value = type::value);
@ -227,26 +227,6 @@ namespace detail
return choose_call(iter, typename traits::category_of<Iterator>::type()); 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 #endif

View File

@ -8,10 +8,12 @@
#define FUSION_FIND_05052005_1107 #define FUSION_FIND_05052005_1107
#include <boost/fusion/algorithm/query/detail/find_if.hpp> #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/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.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/fusion/support/category_of.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_const.hpp>
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
@ -25,29 +27,26 @@ namespace boost { namespace fusion
template < template <
typename Sequence typename Sequence
, typename T , typename T
, bool is_associative_sequence = traits::is_associative<Sequence>::value > >
struct find; struct find
template <typename Sequence, typename T>
struct find<Sequence, T, false>
{ {
typedef typedef
detail::static_seq_find_if< detail::static_find_if<
typename result_of::begin<Sequence>::type typename result_of::begin<Sequence>::type
, typename result_of::end<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; filter;
typedef typename filter::type type; 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> template <typename T, typename Sequence>
@ -59,7 +58,7 @@ namespace boost { namespace fusion
find(Sequence& seq) find(Sequence& seq)
{ {
typedef typename result_of::find<Sequence, T>::filter filter; typedef typename result_of::find<Sequence, T>::filter filter;
return filter::call(seq); return filter::call(fusion::begin(seq));
} }
template <typename T, typename Sequence> template <typename T, typename Sequence>
@ -67,7 +66,7 @@ namespace boost { namespace fusion
find(Sequence const& seq) find(Sequence const& seq)
{ {
typedef typename result_of::find<Sequence const, T>::filter filter; 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/algorithm/query/detail/find_if.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.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/utility/enable_if.hpp>
#include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_const.hpp>
@ -20,13 +24,18 @@ namespace boost { namespace fusion
template <typename Sequence, typename Pred> template <typename Sequence, typename Pred>
struct find_if struct find_if
{ {
typedef typename typedef
detail::static_find_if< detail::static_find_if<
typename result_of::begin<Sequence>::type typename result_of::begin<Sequence>::type
, typename result_of::end<Sequence>::type , typename result_of::end<Sequence>::type
, Pred , mpl::bind1<
>::type typename mpl::lambda<Pred>::type
type; , mpl::bind1<mpl::quote1<value_of>,mpl::_1>
>
>
filter;
typedef typename filter::type type;
}; };
} }
@ -38,14 +47,7 @@ namespace boost { namespace fusion
>::type >::type
find_if(Sequence& seq) find_if(Sequence& seq)
{ {
typedef typedef typename result_of::find_if<Sequence, Pred>::filter filter;
detail::static_find_if<
typename result_of::begin<Sequence>::type
, typename result_of::end<Sequence>::type
, Pred
>
filter;
return filter::call(fusion::begin(seq)); 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 inline typename result_of::find_if<Sequence const, Pred>::type const
find_if(Sequence const& seq) find_if(Sequence const& seq)
{ {
typedef typedef typename result_of::find_if<Sequence, Pred>::filter filter;
detail::static_find_if<
typename result_of::begin<Sequence const>::type
, typename result_of::end<Sequence const>::type
, Pred
>
filter;
return filter::call(fusion::begin(seq)); return filter::call(fusion::begin(seq));
} }
}} }}

View File

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

View File

@ -45,6 +45,7 @@ namespace boost { namespace fusion {
sequence_base<deque<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, T)> > sequence_base<deque<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, T)> >
{ {
typedef deque_tag fusion_tag; 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_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 typename detail::deque_initial_size<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, T)>::type size;
typedef mpl::int_<size::value> next_up; 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) 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) 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> #ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_BEGIN_IMPL_HPP
#include <boost/type_traits/is_const.hpp> #define BOOST_FUSION_CONTAINER_MAP_DETAIL_BEGIN_IMPL_HPP
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.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> template <typename Seq>
struct begin_impl; struct apply
template <>
struct begin_impl<map_tag>
{ {
template <typename Sequence> typedef
struct apply basic_iterator<
map_iterator_tag
, typename Seq::category
, Seq
, 0
>
type;
static type
call(Seq& seq)
{ {
typedef typename return type(seq,0);
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());
}
};
}; };
} };
}} }}}
#endif #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) 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) 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> template <typename Seq>
struct end_impl; struct apply
template <>
struct end_impl<map_tag>
{ {
template <typename Sequence> typedef
struct apply basic_iterator<
map_iterator_tag
, typename Seq::category
, Seq
, Seq::size::value
>
type;
static type
call(Seq& seq)
{ {
typedef typename return type(seq,0);
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());
}
};
}; };
} };
}} }}}
#endif #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/category_of.hpp>
#include <boost/fusion/support/detail/access.hpp> #include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/container/map/map_fwd.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/begin_impl.hpp>
#include <boost/fusion/container/map/detail/end_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_of_impl.hpp>
#include <boost/fusion/container/map/detail/value_at_key_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/fusion/container/vector/vector.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
#include <boost/mpl/bool.hpp> #include <boost/mpl/bool.hpp>
@ -23,7 +25,6 @@
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
struct void_; struct void_;
struct map_tag;
struct fusion_sequence_tag; struct fusion_sequence_tag;
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_MAP_SIZE, typename T)> template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_MAP_SIZE, typename T)>
@ -49,7 +50,6 @@ namespace boost { namespace fusion
: data(rhs) {} : data(rhs) {}
#include <boost/fusion/container/map/detail/map_forward_ctor.hpp> #include <boost/fusion/container/map/detail/map_forward_ctor.hpp>
#include <boost/fusion/container/map/detail/map_lookup.hpp>
template <typename T> template <typename T>
map& map&

View File

@ -13,6 +13,8 @@
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
struct void_; struct void_;
struct map_tag;
struct map_iterator_tag;
template < template <
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( 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) 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) 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> #ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_BEGIN_IMPL_HPP
#include <boost/type_traits/is_const.hpp> #define BOOST_FUSION_CONTAINER_SET_DETAIL_BEGIN_IMPL_HPP
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.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> template <typename Seq>
struct begin_impl; struct apply
template <>
struct begin_impl<set_tag>
{ {
template <typename Sequence> typedef
struct apply basic_iterator<
set_iterator_tag
, typename Seq::category
, Seq
, 0
>
type;
static type
call(Seq& seq)
{ {
typedef typename return type(seq,0);
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());
}
};
}; };
} };
}} }}}
#endif #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) 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) 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> template <typename Seq>
struct end_impl; struct apply
template <>
struct end_impl<set_tag>
{ {
template <typename Sequence> typedef
struct apply basic_iterator<
set_iterator_tag
, typename Seq::category
, Seq
, Seq::size::value
>
type;
static type
call(Seq& seq)
{ {
typedef typename return type(seq,0);
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());
}
};
}; };
} };
}} }}}
#endif #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/category_of.hpp>
#include <boost/fusion/support/detail/access.hpp> #include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/container/set/set_fwd.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/begin_impl.hpp>
#include <boost/fusion/container/set/detail/end_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_of_impl.hpp>
#include <boost/fusion/container/set/detail/value_at_key_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/fusion/container/vector/vector.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
#include <boost/mpl/bool.hpp> #include <boost/mpl/bool.hpp>
@ -23,7 +25,6 @@
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
struct void_; struct void_;
struct set_tag;
struct fusion_sequence_tag; struct fusion_sequence_tag;
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_SET_SIZE, typename T)> template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_SET_SIZE, typename T)>
@ -49,7 +50,6 @@ namespace boost { namespace fusion
: data(rhs) {} : data(rhs) {}
#include <boost/fusion/container/set/detail/set_forward_ctor.hpp> #include <boost/fusion/container/set/detail/set_forward_ctor.hpp>
#include <boost/fusion/container/set/detail/set_lookup.hpp>
template <typename T> template <typename T>
set& set&

View File

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

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> template <typename First, typename Last>
struct distance : struct distance :
distance_detail::linear_distance<First, Last> 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 #define BOOST_FUSION_AT_KEY_20060304_1755
#include <boost/type_traits/is_const.hpp> #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/tag_of.hpp>
#include <boost/fusion/support/detail/access.hpp> #include <boost/fusion/support/detail/access.hpp>
@ -25,15 +27,28 @@ namespace boost { namespace fusion
template <typename Tag> template <typename Tag>
struct at_key_impl struct at_key_impl
{ {
template <typename Sequence, typename Key> template <typename Seq, typename Key>
struct apply; 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 <> template <>
struct at_key_impl<sequence_facade_tag> struct at_key_impl<sequence_facade_tag>
{ {
template <typename Sequence, typename Key> template <typename Sequence, typename Key>
struct apply : Sequence::template at_key<Sequence, Key> {}; struct apply : Sequence::template at_key_impl<Sequence, Key> {};
}; };
template <> template <>

View File

@ -7,9 +7,11 @@
#if !defined(FUSION_HAS_KEY_09232005_1454) #if !defined(FUSION_HAS_KEY_09232005_1454)
#define 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/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 namespace boost { namespace fusion
{ {
@ -26,10 +28,14 @@ namespace boost { namespace fusion
template <typename Tag> template <typename Tag>
struct has_key_impl struct has_key_impl
{ {
template <typename Sequence, typename Key> template <typename Seq, typename Key>
struct apply struct apply
: mpl::not_<is_same<typename Sequence:: : mpl::not_<
template meta_at_impl<Key>::type, void_> > 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 #define FUSION_VALUE_AT_KEY_05052005_0229
#include <boost/mpl/int.hpp> #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> #include <boost/fusion/support/tag_of.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
@ -24,8 +26,12 @@ namespace boost { namespace fusion
template <typename Tag> template <typename Tag>
struct value_at_key_impl struct value_at_key_impl
{ {
template <typename Sequence, typename Key> template <typename Seq, typename Key>
struct apply; struct apply
: result_of::value_of_data<
typename result_of::find<Seq, Key>::type
>
{};
}; };
template <> template <>

View File

@ -11,7 +11,7 @@ namespace boost { namespace fusion
{ {
struct filter_view_tag; struct filter_view_tag;
template <typename First, typename Last, typename Pred> template <typename Category, typename First, typename Last, typename Pred>
struct filter_iterator; struct filter_iterator;
namespace extension namespace extension
@ -28,7 +28,8 @@ namespace boost { namespace fusion
typedef typename Sequence::first_type first_type; typedef typename Sequence::first_type first_type;
typedef typename Sequence::last_type last_type; typedef typename Sequence::last_type last_type;
typedef typename Sequence::pred_type pred_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 static type
call(Sequence& s) 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; struct filter_view_tag;
template <typename First, typename Last, typename Pred> template <typename Category, typename First, typename Last, typename Pred>
struct filter_iterator; struct filter_iterator;
namespace extension namespace extension
@ -27,7 +27,8 @@ namespace boost { namespace fusion
{ {
typedef typename Sequence::last_type last_type; typedef typename Sequence::last_type last_type;
typedef typename Sequence::pred_type pred_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 static type
call(Sequence& s) 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 #define FUSION_NEXT_IMPL_06052005_0900
#include <boost/fusion/algorithm/query/detail/find_if.hpp> #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/eval_if.hpp>
#include <boost/mpl/identity.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 namespace boost { namespace fusion
{ {
struct filter_view_iterator_tag; struct filter_view_iterator_tag;
template <typename First, typename Last, typename Pred> template <typename Category, typename First, typename Last, typename Pred>
struct filter_iterator; struct filter_iterator;
namespace extension namespace extension
@ -32,6 +37,7 @@ namespace boost { namespace fusion
typedef typename Iterator::first_type first_type; typedef typename Iterator::first_type first_type;
typedef typename Iterator::last_type last_type; typedef typename Iterator::last_type last_type;
typedef typename Iterator::pred_type pred_type; typedef typename Iterator::pred_type pred_type;
typedef typename Iterator::category category;
typedef typename typedef typename
mpl::eval_if< mpl::eval_if<
@ -41,12 +47,19 @@ namespace boost { namespace fusion
>::type >::type
next_type; next_type;
typedef typename detail::static_find_if< typedef typename
next_type, last_type, pred_type> 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; filter;
typedef filter_iterator< typedef filter_iterator<
typename filter::type, last_type, pred_type> category, typename filter::type, last_type, pred_type>
type; type;
static 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/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/mpl/bool.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 namespace boost { namespace fusion
{ {
@ -29,7 +33,13 @@ namespace boost { namespace fusion
{ {
typedef filter_view_tag fusion_tag; typedef filter_view_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL 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_sequence_tag>
, mpl::identity<forward_traversal_tag>
>::type
category;
typedef mpl::true_ is_view; typedef mpl::true_ is_view;
typedef typename result_of::begin<Sequence>::type first_type; 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/iterator/mpl/convert_iterator.hpp>
#include <boost/fusion/adapted/mpl/mpl_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/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/deref_impl.hpp>
#include <boost/fusion/view/filter_view/detail/next_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/value_of_impl.hpp>
#include <boost/fusion/view/filter_view/detail/equal_to_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 namespace boost { namespace fusion
{ {
struct filter_view_iterator_tag; struct filter_view_iterator_tag;
struct forward_traversal_tag; struct forward_traversal_tag;
template <typename First, typename Last, typename Pred> template <typename Category, typename First, typename Last, typename Pred>
struct filter_iterator : iterator_base<filter_iterator<First, Last, Pred> > struct filter_iterator : iterator_base<filter_iterator<Category, First, Last, Pred> >
{ {
typedef convert_iterator<First> first_converter; typedef convert_iterator<First> first_converter;
typedef typename first_converter::type first_iter; typedef typename first_converter::type first_iter;
@ -30,8 +39,17 @@ namespace boost { namespace fusion
typedef typename last_converter::type last_iter; typedef typename last_converter::type last_iter;
typedef filter_view_iterator_tag fusion_tag; typedef filter_view_iterator_tag fusion_tag;
typedef forward_traversal_tag category; typedef Category category;
typedef detail::static_find_if<first_iter, last_iter, Pred> filter; 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 typename filter::type first_type;
typedef last_iter last_type; typedef last_iter last_type;
typedef Pred pred_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/at_impl.hpp>
#include <boost/fusion/view/iterator_range/detail/value_at_impl.hpp> #include <boost/fusion/view/iterator_range/detail/value_at_impl.hpp>
#include <boost/fusion/adapted/mpl/mpl_iterator.hpp> #include <boost/fusion/adapted/mpl/mpl_iterator.hpp>
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {

View File

@ -14,7 +14,7 @@ namespace boost { namespace fusion
{ {
struct joint_view_tag; struct joint_view_tag;
template <typename First, typename Last, typename Concat> template <typename Category, typename First, typename Last, typename Concat>
struct joint_view_iterator; struct joint_view_iterator;
namespace extension namespace extension
@ -31,13 +31,14 @@ namespace boost { namespace fusion
typedef typename Sequence::first_type first_type; typedef typename Sequence::first_type first_type;
typedef typename Sequence::last_type last_type; typedef typename Sequence::last_type last_type;
typedef typename Sequence::concat_type concat_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 result_of::equal_to<first_type, last_type> equal_to;
typedef typename typedef typename
mpl::if_< mpl::if_<
equal_to equal_to
, concat_type , concat_type
, joint_view_iterator<first_type, last_type, concat_type> , joint_view_iterator<category, first_type, last_type, concat_type>
>::type >::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; 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; struct joint_view_iterator;
namespace extension namespace extension
@ -32,6 +32,7 @@ namespace boost { namespace fusion
typedef typename Iterator::first_type first_type; typedef typename Iterator::first_type first_type;
typedef typename Iterator::last_type last_type; typedef typename Iterator::last_type last_type;
typedef typename Iterator::concat_type concat_type; typedef typename Iterator::concat_type concat_type;
typedef typename Iterator::category category;
typedef typename result_of::next<first_type>::type next_type; typedef typename result_of::next<first_type>::type next_type;
typedef result_of::equal_to<next_type, last_type> equal_to; typedef result_of::equal_to<next_type, last_type> equal_to;
@ -39,7 +40,7 @@ namespace boost { namespace fusion
mpl::if_< mpl::if_<
equal_to equal_to
, concat_type , concat_type
, joint_view_iterator<next_type, last_type, concat_type> , joint_view_iterator<category, next_type, last_type, concat_type>
>::type >::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/if.hpp>
#include <boost/mpl/plus.hpp> #include <boost/mpl/plus.hpp>
#include <boost/mpl/bool.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 namespace boost { namespace fusion
{ {
@ -31,7 +34,16 @@ namespace boost { namespace fusion
{ {
typedef joint_view_tag fusion_tag; typedef joint_view_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL 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_sequence_tag>
, mpl::identity<forward_traversal_tag>
>::type
category;
typedef mpl::true_ is_view; typedef mpl::true_ is_view;
typedef typename result_of::begin<Sequence1>::type first_type; 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/deref_impl.hpp>
#include <boost/fusion/view/joint_view/detail/next_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/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> #include <boost/static_assert.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
@ -21,9 +24,9 @@ namespace boost { namespace fusion
struct joint_view_iterator_tag; struct joint_view_iterator_tag;
struct forward_traversal_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 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<First> first_converter;
typedef convert_iterator<Last> last_converter; typedef convert_iterator<Last> last_converter;
@ -34,7 +37,7 @@ namespace boost { namespace fusion
typedef typename concat_converter::type concat_type; typedef typename concat_converter::type concat_type;
typedef joint_view_iterator_tag fusion_tag; 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)); BOOST_STATIC_ASSERT((!result_of::equal_to<first_type, last_type>::value));
joint_view_iterator(First const& first, Concat const& concat) joint_view_iterator(First const& first, Concat const& concat)

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

@ -20,6 +20,9 @@
#include <boost/type_traits/is_base_of.hpp> #include <boost/type_traits/is_base_of.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <boost/mpl/bool.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 namespace boost { namespace fusion
{ {
@ -32,8 +35,15 @@ namespace boost { namespace fusion
typedef reverse_view_tag fusion_tag; typedef reverse_view_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef mpl::true_ is_view; typedef mpl::true_ is_view;
typedef typename traits::category_of<Sequence>::type seq_category;
typedef typename traits::category_of<Sequence>::type category; typedef typename
mpl::eval_if<
traits::is_associative<Sequence>
, mpl::inherit2<seq_category,associative_sequence_tag>
, mpl::identity<seq_category>
>::type
category;
typedef typename result_of::begin<Sequence>::type first_type; typedef typename result_of::begin<Sequence>::type first_type;
typedef typename result_of::end<Sequence>::type last_type; typedef typename result_of::end<Sequence>::type last_type;
typedef typename result_of::size<Sequence>::type size; typedef typename result_of::size<Sequence>::type size;

View File

@ -17,6 +17,9 @@
#include <boost/fusion/view/reverse_view/detail/advance_impl.hpp> #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/distance_impl.hpp>
#include <boost/fusion/view/reverse_view/detail/value_of_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/type_traits/is_base_of.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>

View File

@ -66,8 +66,8 @@ main()
std::cout << tuple_close(']'); std::cout << tuple_close(']');
std::cout << tuple_delimiter(", "); std::cout << tuple_delimiter(", ");
test_set(as_set(erase_key<char>(make_set(1, 'x', 1.5, std::string("hello"))))); test_set(erase_key<char>(make_set(1, 'x', 1.5, std::string("hello"))));
test_map(as_map(erase_key<_2>(make_map<_1, _2, _3, _4>(1, 'x', 1.5, "hello")))); test_map(erase_key<_2>(make_map<_1, _2, _3, _4>(1, 'x', 1.5, "hello")));
return boost::report_errors(); return boost::report_errors();
} }

View File

@ -33,7 +33,7 @@ main()
std::cout << as_set(make_list(1, 1.23, "harru")) << std::endl; std::cout << as_set(make_list(1, 1.23, "harru")) << std::endl;
std::cout << as_set(push_back(empty, 999)) << std::endl; std::cout << as_set(push_back(empty, 999)) << std::endl;
BOOST_TEST(as_list(as_set(make_list(1, 1.23, "harru"))) BOOST_TEST(as_list(as_set(make_list(1, 1.23, "harru")))
== make_list(1, 1.23, std::string("harru"))); == make_list(1, 1.23, std::string("harru")));
BOOST_TEST(as_list(as_set(push_back(empty, 999))) BOOST_TEST(as_list(as_set(push_back(empty, 999)))
== push_back(empty, 999)); == push_back(empty, 999));

View File

@ -13,6 +13,12 @@
#include <boost/fusion/view/filter_view/filter_view.hpp> #include <boost/fusion/view/filter_view/filter_view.hpp>
#include <boost/fusion/container/generation/make_vector.hpp> #include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/container/map.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/value_of_data.hpp>
#include <boost/fusion/iterator/deref_data.hpp>
#include <boost/type_traits/is_class.hpp> #include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_same.hpp>
#include <boost/mpl/arg.hpp> #include <boost/mpl/arg.hpp>
@ -62,22 +68,6 @@ main()
std::cout << tuple_close(']'); std::cout << tuple_close(']');
std::cout << tuple_delimiter(", "); std::cout << tuple_delimiter(", ");
{ // Testing the static find_if (internal function)
typedef vector<int, char, long, X> vector_type;
vector_type v(1, 'x', 987654, X());
typedef vector_iterator<vector_type, 0> begin;
typedef vector_iterator<vector_type, 4> end;
typedef detail::static_find_if<begin, end, is_same<_, long> > filter;
typedef filter::type type;
BOOST_TEST(*type(v) == 987654);
std::cout << *type(v) << std::endl;
std::cout << *filter::call(begin(v)) << std::endl;
BOOST_TEST(*type(v) == *filter::call(begin(v)));
}
{ {
typedef vector<Y, char, long, X, bool, double> vector_type; typedef vector<Y, char, long, X, bool, double> vector_type;
@ -115,6 +105,23 @@ main()
BOOST_MPL_ASSERT((result_of::equal_to<result_of::begin<filter_view_type>::type, result_of::end<filter_view_type>::type>)); BOOST_MPL_ASSERT((result_of::equal_to<result_of::begin<filter_view_type>::type, result_of::end<filter_view_type>::type>));
} }
{
typedef map<pair<void, int>, pair<double, std::string> > map_type;
map_type m(make_pair<void>(0), make_pair<double>("Bond"));
typedef filter_view<map_type const, is_same<_, pair<double, std::string> > > filter_view_type;
filter_view_type f(m);
BOOST_MPL_ASSERT((result_of::has_key<filter_view_type, double>::type));
BOOST_MPL_ASSERT_NOT((result_of::has_key<filter_view_type, void>::type));
BOOST_MPL_ASSERT((is_same<result_of::key_of<result_of::begin<filter_view_type>::type>::type, double>));
BOOST_MPL_ASSERT((is_same<result_of::value_of_data<result_of::begin<filter_view_type>::type>::type, std::string>));
std::cout << deref_data(begin(f)) << std::endl;
BOOST_TEST((deref_data(begin(f)) == "Bond"));
}
return boost::report_errors(); return boost::report_errors();
} }

View File

@ -5,15 +5,23 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/ ==============================================================================*/
#include <boost/detail/lightweight_test.hpp> #include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/map.hpp>
#include <boost/fusion/container/vector/vector.hpp> #include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/generation/make_vector.hpp> #include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/view/iterator_range/iterator_range.hpp> #include <boost/fusion/view/iterator_range/iterator_range.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp> #include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/io/out.hpp> #include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/value_of_data.hpp>
#include <boost/fusion/iterator/deref_data.hpp>
#include <boost/mpl/vector_c.hpp> #include <boost/mpl/vector_c.hpp>
#include <boost/mpl/begin.hpp> #include <boost/mpl/begin.hpp>
#include <boost/mpl/next.hpp> #include <boost/mpl/next.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
int int
@ -76,6 +84,31 @@ main()
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2); BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
} }
{
typedef map<pair<void,std::string>, pair<double,char>,pair<void*, int> > map_type;
map_type m(make_pair<void>("foo"), make_pair<double>('x'), make_pair<void*>(2));
typedef iterator_range<
result_of::begin<map_type>::type
, result_of::advance_c<result_of::begin<map_type>::type,2>::type
> range_type;
range_type r(begin(m), advance_c<2>(begin(m)));
BOOST_MPL_ASSERT((result_of::has_key<range_type, void>::type));
BOOST_MPL_ASSERT((result_of::has_key<range_type, double>::type));
BOOST_MPL_ASSERT((boost::is_same<result_of::key_of<result_of::begin<range_type>::type>::type, void>));
BOOST_MPL_ASSERT((boost::is_same<result_of::key_of<result_of::next<result_of::begin<range_type>::type>::type>::type, double>));
BOOST_MPL_ASSERT((boost::is_same<result_of::value_of_data<result_of::begin<range_type>::type>::type, std::string>));
BOOST_MPL_ASSERT((boost::is_same<result_of::value_of_data<result_of::next<result_of::begin<range_type>::type>::type>::type, char>));
std::cout << deref_data(begin(r)) << std::endl;
std::cout << deref_data(next(begin(r))) << std::endl;
BOOST_TEST((deref_data(begin(r)) == "foo"));
BOOST_TEST((deref_data(next(begin(r))) == 'x'));
}
return boost::report_errors(); return boost::report_errors();
} }

View File

@ -5,13 +5,22 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/ ==============================================================================*/
#include <boost/detail/lightweight_test.hpp> #include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/map.hpp>
#include <boost/fusion/container/set.hpp>
#include <boost/fusion/container/vector/vector.hpp> #include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/view/joint_view/joint_view.hpp> #include <boost/fusion/view/joint_view/joint_view.hpp>
#include <boost/fusion/sequence/io/out.hpp> #include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp> #include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/container/generation/make_vector.hpp> #include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp> #include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/mpl/vector_c.hpp> #include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/iterator/deref_data.hpp>
#include <boost/mpl/assert.hpp>
#include <string>
struct X struct X
{ {
@ -139,6 +148,40 @@ main()
} }
} }
{
typedef map<pair<void,int> > map_type;
map_type m(make_pair<void>(0));
typedef set<std::string, float> set_type;
set_type s("foo", 1.3f);
typedef joint_view<map_type, set_type> joint_view_type;
joint_view_type j(m,s);
BOOST_MPL_ASSERT((result_of::has_key<joint_view_type, void>::type));
BOOST_MPL_ASSERT((result_of::has_key<joint_view_type, std::string>::type));
BOOST_MPL_ASSERT((result_of::has_key<joint_view_type, float>::type));
BOOST_MPL_ASSERT((boost::is_same<result_of::key_of<result_of::begin<joint_view_type>::type>::type, void>));
BOOST_MPL_ASSERT((boost::is_same<result_of::key_of<result_of::next<result_of::begin<joint_view_type>::type>::type>::type, std::string>));
BOOST_MPL_ASSERT((boost::is_same<
result_of::key_of<result_of::next<result_of::next<result_of::begin<joint_view_type>::type>::type>::type>::type
, float>));
BOOST_MPL_ASSERT((boost::is_same<result_of::value_of_data<result_of::begin<joint_view_type>::type>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<result_of::value_of_data<result_of::next<result_of::begin<joint_view_type>::type>::type>::type, std::string>));
BOOST_MPL_ASSERT((boost::is_same<
result_of::value_of_data<result_of::next<result_of::next<result_of::begin<joint_view_type>::type>::type>::type>::type
, float>));
std::cout << deref_data(begin(j)) << std::endl;
std::cout << deref_data(boost::fusion::next(begin(j))) << std::endl;
std::cout << deref_data(next(boost::fusion::next(begin(j)))) << std::endl;
BOOST_TEST((deref_data(begin(j)) == 0));
BOOST_TEST((deref_data(boost::fusion::next(begin(j))) == "foo"));
BOOST_TEST((deref_data(next(boost::fusion::next(begin(j)))) == 1.3f));
}
return boost::report_errors(); return boost::report_errors();
} }

View File

@ -10,7 +10,12 @@
#include <boost/fusion/sequence/intrinsic/at_key.hpp> #include <boost/fusion/sequence/intrinsic/at_key.hpp>
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp> #include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp> #include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/io/out.hpp> #include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/deref_data.hpp>
#include <boost/fusion/iterator/value_of_data.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/support/pair.hpp> #include <boost/fusion/support/pair.hpp>
#include <boost/fusion/support/category_of.hpp> #include <boost/fusion/support/category_of.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
@ -59,6 +64,17 @@ main()
BOOST_STATIC_ASSERT((result_of::has_key<map_type, int>::value)); BOOST_STATIC_ASSERT((result_of::has_key<map_type, int>::value));
BOOST_STATIC_ASSERT((result_of::has_key<map_type, double>::value)); BOOST_STATIC_ASSERT((result_of::has_key<map_type, double>::value));
BOOST_STATIC_ASSERT((!result_of::has_key<map_type, std::string>::value)); BOOST_STATIC_ASSERT((!result_of::has_key<map_type, std::string>::value));
std::cout << deref_data(begin(m)) << std::endl;
std::cout << deref_data(next(begin(m))) << std::endl;
BOOST_TEST(deref_data(begin(m)) == 'X');
BOOST_TEST(deref_data(next(begin(m))) == "Men");
BOOST_STATIC_ASSERT((is_same<result_of::key_of<result_of::begin<map_type>::type>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of::key_of<result_of::next<result_of::begin<map_type>::type>::type>::type, double>::value));
BOOST_STATIC_ASSERT((is_same<result_of::value_of_data<result_of::begin<map_type>::type>::type, char>::value));
BOOST_STATIC_ASSERT((is_same<result_of::value_of_data<result_of::next<result_of::begin<map_type>::type>::type>::type, std::string>::value));
} }
{ {

View File

@ -10,7 +10,12 @@
#include <boost/fusion/sequence/intrinsic/at_key.hpp> #include <boost/fusion/sequence/intrinsic/at_key.hpp>
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp> #include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
#include <boost/fusion/sequence/intrinsic/has_key.hpp> #include <boost/fusion/sequence/intrinsic/has_key.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/io/out.hpp> #include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/iterator/key_of.hpp>
#include <boost/fusion/iterator/deref_data.hpp>
#include <boost/fusion/iterator/value_of_data.hpp>
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/support/pair.hpp> #include <boost/fusion/support/pair.hpp>
#include <boost/fusion/support/category_of.hpp> #include <boost/fusion/support/category_of.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
@ -48,12 +53,23 @@ main()
boost::is_same<result_of::value_at_key<set_type, int>::type, int>::value)); boost::is_same<result_of::value_at_key<set_type, int>::type, int>::value));
BOOST_STATIC_ASSERT(( BOOST_STATIC_ASSERT((
boost::is_same<result_of::value_at_key<set_type, std::string>::type, std::string>::value)); boost::is_same<result_of::value_at_key<set_type, std::string>::type, std::string>::value));
std::cout << m << std::endl; std::cout << m << std::endl;
BOOST_STATIC_ASSERT((result_of::has_key<set_type, int>::value)); BOOST_STATIC_ASSERT((result_of::has_key<set_type, int>::value));
BOOST_STATIC_ASSERT((result_of::has_key<set_type, std::string>::value)); BOOST_STATIC_ASSERT((result_of::has_key<set_type, std::string>::value));
BOOST_STATIC_ASSERT((!result_of::has_key<set_type, double>::value)); BOOST_STATIC_ASSERT((!result_of::has_key<set_type, double>::value));
std::cout << deref_data(begin(m)) << std::endl;
std::cout << deref_data(next(begin(m))) << std::endl;
BOOST_TEST(deref_data(begin(m)) == 123);
BOOST_TEST(deref_data(next(begin(m))) == "Hola");
BOOST_STATIC_ASSERT((is_same<result_of::key_of<result_of::begin<set_type>::type>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of::key_of<result_of::next<result_of::begin<set_type>::type>::type>::type, std::string>::value));
BOOST_STATIC_ASSERT((is_same<result_of::value_of_data<result_of::begin<set_type>::type>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of::value_of_data<result_of::next<result_of::begin<set_type>::type>::type>::type, std::string>::value));
} }
{ {