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

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

View File

@@ -0,0 +1,37 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_DEREF_DATA_IMPL_HPP
#include <boost/fusion/iterator/deref_data.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_data_impl;
template <>
struct deref_data_impl<joint_view_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::deref_data<typename It::first_type>::type
type;
static type
call(It const& it)
{
return fusion::deref_data(it.first);
}
};
};
}}}
#endif

View File

@@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_KEY_OF_IMPL_HPP
#define BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_KEY_OF_IMPL_HPP
#include <boost/fusion/iterator/key_of.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct key_of_impl;
template <>
struct key_of_impl<joint_view_iterator_tag>
{
template <typename It>
struct apply
: result_of::key_of<typename It::first_type>
{};
};
}}}
#endif

View File

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

View File

@@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP
#include <boost/fusion/iterator/value_of_data.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_data_impl;
template <>
struct value_of_data_impl<joint_view_iterator_tag>
{
template <typename It>
struct apply
: result_of::value_of_data<typename It::first_type>
{};
};
}}}
#endif

View File

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

View File

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