forked from boostorg/fusion
creating branch for fusion 2.1
[SVN r40232]
This commit is contained in:
66
include/boost/fusion/view/joint_view/detail/begin_impl.hpp
Normal file
66
include/boost/fusion/view/joint_view/detail/begin_impl.hpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*=============================================================================
|
||||
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_BEGIN_IMPL_07162005_0115)
|
||||
#define FUSION_BEGIN_IMPL_07162005_0115
|
||||
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_tag;
|
||||
|
||||
template <typename First, typename Last, typename Concat>
|
||||
struct joint_view_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct begin_impl;
|
||||
|
||||
template <>
|
||||
struct begin_impl<joint_view_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Sequence::first_type first_type;
|
||||
typedef typename Sequence::last_type last_type;
|
||||
typedef typename Sequence::concat_type concat_type;
|
||||
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>
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Sequence& s, mpl::true_)
|
||||
{
|
||||
return s.concat();
|
||||
}
|
||||
|
||||
static type
|
||||
call(Sequence& s, mpl::false_)
|
||||
{
|
||||
return type(s.first(), s.concat());
|
||||
}
|
||||
|
||||
static type
|
||||
call(Sequence& s)
|
||||
{
|
||||
return call(s, equal_to());
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
29
include/boost/fusion/view/joint_view/detail/deref_impl.hpp
Normal file
29
include/boost/fusion/view/joint_view/detail/deref_impl.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*=============================================================================
|
||||
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_DEREF_IMPL_07162005_0137)
|
||||
#define FUSION_DEREF_IMPL_07162005_0137
|
||||
|
||||
#include <boost/fusion/iterator/detail/adapt_deref_traits.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template <>
|
||||
struct deref_impl<joint_view_iterator_tag>
|
||||
: detail::adapt_deref_traits {};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
40
include/boost/fusion/view/joint_view/detail/end_impl.hpp
Normal file
40
include/boost/fusion/view/joint_view/detail/end_impl.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*=============================================================================
|
||||
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_END_IMPL_07162005_0128)
|
||||
#define FUSION_END_IMPL_07162005_0128
|
||||
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct end_impl;
|
||||
|
||||
template <>
|
||||
struct end_impl<joint_view_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Sequence::concat_last_type type;
|
||||
|
||||
static type
|
||||
call(Sequence& s)
|
||||
{
|
||||
return s.concat_last();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
70
include/boost/fusion/view/joint_view/detail/next_impl.hpp
Normal file
70
include/boost/fusion/view/joint_view/detail/next_impl.hpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/*=============================================================================
|
||||
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_NEXT_IMPL_07162005_0136)
|
||||
#define FUSION_NEXT_IMPL_07162005_0136
|
||||
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_iterator_tag;
|
||||
|
||||
template <typename First, typename Last, typename Concat>
|
||||
struct joint_view_iterator;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template <>
|
||||
struct next_impl<joint_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::first_type first_type;
|
||||
typedef typename Iterator::last_type last_type;
|
||||
typedef typename Iterator::concat_type concat_type;
|
||||
typedef typename result_of::next<first_type>::type next_type;
|
||||
typedef result_of::equal_to<next_type, last_type> equal_to;
|
||||
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
equal_to
|
||||
, concat_type
|
||||
, joint_view_iterator<next_type, last_type, concat_type>
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i, mpl::true_)
|
||||
{
|
||||
return i.concat;
|
||||
}
|
||||
|
||||
static type
|
||||
call(Iterator const& i, mpl::false_)
|
||||
{
|
||||
return type(fusion::next(i.first), i.concat);
|
||||
}
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return call(i, equal_to());
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -0,0 +1,29 @@
|
||||
/*=============================================================================
|
||||
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_VALUE_IMPL_07162005_0132)
|
||||
#define FUSION_VALUE_IMPL_07162005_0132
|
||||
|
||||
#include <boost/fusion/iterator/detail/adapt_value_traits.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_iterator_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_of_impl;
|
||||
|
||||
template <>
|
||||
struct value_of_impl<joint_view_iterator_tag>
|
||||
: detail::adapt_value_traits {};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
61
include/boost/fusion/view/joint_view/joint_view.hpp
Normal file
61
include/boost/fusion/view/joint_view/joint_view.hpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/*=============================================================================
|
||||
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_JOINT_VIEW_07162005_0140)
|
||||
#define FUSION_JOINT_VIEW_07162005_0140
|
||||
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/view/joint_view/joint_view_iterator.hpp>
|
||||
#include <boost/fusion/view/joint_view/detail/begin_impl.hpp>
|
||||
#include <boost/fusion/view/joint_view/detail/end_impl.hpp>
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/plus.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_tag;
|
||||
struct forward_traversal_tag;
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
template <typename Sequence1, typename Sequence2>
|
||||
struct joint_view : sequence_base<joint_view<Sequence1, Sequence2> >
|
||||
{
|
||||
typedef joint_view_tag fusion_tag;
|
||||
typedef fusion_sequence_tag tag; // this gets picked up by MPL
|
||||
typedef forward_traversal_tag category;
|
||||
typedef mpl::true_ is_view;
|
||||
|
||||
typedef typename result_of::begin<Sequence1>::type first_type;
|
||||
typedef typename result_of::end<Sequence1>::type last_type;
|
||||
typedef typename result_of::begin<Sequence2>::type concat_type;
|
||||
typedef typename result_of::end<Sequence2>::type concat_last_type;
|
||||
typedef typename mpl::plus<result_of::size<Sequence1>, result_of::size<Sequence2> >::type size;
|
||||
|
||||
joint_view(Sequence1& seq1, Sequence2& seq2)
|
||||
: seq1(seq1)
|
||||
, seq2(seq2)
|
||||
{}
|
||||
|
||||
first_type first() const { return fusion::begin(seq1); }
|
||||
concat_type concat() const { return fusion::begin(seq2); }
|
||||
concat_last_type concat_last() const { return fusion::end(seq2); }
|
||||
|
||||
private:
|
||||
|
||||
typename mpl::if_<traits::is_view<Sequence1>, Sequence1, Sequence1&>::type seq1;
|
||||
typename mpl::if_<traits::is_view<Sequence2>, Sequence2, Sequence2&>::type seq2;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
52
include/boost/fusion/view/joint_view/joint_view_iterator.hpp
Normal file
52
include/boost/fusion/view/joint_view/joint_view_iterator.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/*=============================================================================
|
||||
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_JOINT_VIEW_ITERATOR_07162005_0140)
|
||||
#define FUSION_JOINT_VIEW_ITERATOR_07162005_0140
|
||||
|
||||
#include <boost/fusion/support/iterator_base.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/iterator/mpl/convert_iterator.hpp>
|
||||
#include <boost/fusion/adapted/mpl/mpl_iterator.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/value_of_impl.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_iterator_tag;
|
||||
struct forward_traversal_tag;
|
||||
|
||||
template <typename First, typename Last, typename Concat>
|
||||
struct joint_view_iterator
|
||||
: iterator_base<joint_view_iterator<First, Last, Concat> >
|
||||
{
|
||||
typedef convert_iterator<First> first_converter;
|
||||
typedef convert_iterator<Last> last_converter;
|
||||
typedef convert_iterator<Concat> concat_converter;
|
||||
|
||||
typedef typename first_converter::type first_type;
|
||||
typedef typename last_converter::type last_type;
|
||||
typedef typename concat_converter::type concat_type;
|
||||
|
||||
typedef joint_view_iterator_tag fusion_tag;
|
||||
typedef forward_traversal_tag category;
|
||||
BOOST_STATIC_ASSERT((!result_of::equal_to<first_type, last_type>::value));
|
||||
|
||||
joint_view_iterator(First const& first, Concat const& concat)
|
||||
: first(first_converter::call(first))
|
||||
, concat(concat_converter::call(concat))
|
||||
{}
|
||||
|
||||
first_type first;
|
||||
concat_type concat;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user