forked from boostorg/fusion
Initial move from Spirit CVS
[SVN r34896]
This commit is contained in:
@ -0,0 +1,76 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
Use, modification and distribution is subject to 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_ADVANCE_IMPL_13122005_1906)
|
||||
#define FUSION_ADVANCE_IMPL_13122005_1906
|
||||
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct transform_view_iterator_tag;
|
||||
struct transform_view_iterator2_tag;
|
||||
|
||||
template<typename First, typename F>
|
||||
struct transform_view_iterator;
|
||||
|
||||
template <typename First1, typename First2, typename F>
|
||||
struct transform_view_iterator2;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct advance_impl;
|
||||
|
||||
// Unary Version
|
||||
template<>
|
||||
struct advance_impl<transform_view_iterator_tag>
|
||||
{
|
||||
template<typename Iterator, typename Dist>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::first_type first_type;
|
||||
typedef typename result_of::advance<first_type, Dist>::type advanced_type;
|
||||
typedef typename Iterator::transform_type transform_type;
|
||||
typedef transform_view_iterator<advanced_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(boost::fusion::advance<Dist>(i.first), i.f);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Binary Version
|
||||
template<>
|
||||
struct advance_impl<transform_view_iterator2_tag>
|
||||
{
|
||||
template<typename Iterator, typename Dist>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::first1_type first1_type;
|
||||
typedef typename Iterator::first2_type first2_type;
|
||||
typedef typename result_of::advance<first1_type, Dist>::type advanced1_type;
|
||||
typedef typename result_of::advance<first2_type, Dist>::type advanced2_type;
|
||||
typedef typename Iterator::transform_type transform_type;
|
||||
typedef transform_view_iterator2<advanced1_type, advanced2_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(
|
||||
boost::fusion::advance<Dist>(i.first1)
|
||||
, boost::fusion::advance<Dist>(i.first2), i.f);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -0,0 +1,37 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_APPLY_TRANSFORM_RESULT_02092006_1936)
|
||||
#define FUSION_APPLY_TRANSFORM_RESULT_02092006_1936
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename F>
|
||||
struct apply_transform_result
|
||||
{
|
||||
template <typename T0, typename T1 = void_>
|
||||
struct apply
|
||||
{
|
||||
typedef typename F::template result<T0, T1>::type type;
|
||||
};
|
||||
|
||||
template <typename T0>
|
||||
struct apply<T0, void_>
|
||||
{
|
||||
typedef typename F::template result<T0>::type type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,69 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_1031)
|
||||
#define FUSION_BEGIN_IMPL_07162005_1031
|
||||
|
||||
#include <boost/fusion/sequence/view/transform_view/transform_view_fwd.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
template <typename First, typename F>
|
||||
struct transform_view_iterator;
|
||||
|
||||
template <typename First1, typename First2, typename F>
|
||||
struct transform_view_iterator2;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct begin_impl;
|
||||
|
||||
// Unary Version
|
||||
template <>
|
||||
struct begin_impl<transform_view_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Sequence::first_type first_type;
|
||||
typedef typename Sequence::transform_type transform_type;
|
||||
typedef transform_view_iterator<first_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Sequence& s)
|
||||
{
|
||||
return type(s.first(), s.f);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Binary Version
|
||||
template <>
|
||||
struct begin_impl<transform_view2_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Sequence::first1_type first1_type;
|
||||
typedef typename Sequence::first2_type first2_type;
|
||||
typedef typename Sequence::transform_type transform_type;
|
||||
typedef transform_view_iterator2<first1_type, first2_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Sequence& s)
|
||||
{
|
||||
return type(s.first1(), s.first2(), s.f);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,76 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_1026)
|
||||
#define FUSION_DEREF_IMPL_07162005_1026
|
||||
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/fusion/iterator/value_of.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/detail/apply_transform_result.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct transform_view_iterator_tag;
|
||||
struct transform_view_iterator2_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
// Unary Version
|
||||
template <>
|
||||
struct deref_impl<transform_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
result_of::value_of<typename Iterator::first_type>::type
|
||||
value_type;
|
||||
|
||||
typedef detail::apply_transform_result<typename Iterator::transform_type> transform_type;
|
||||
typedef typename mpl::apply<transform_type, value_type>::type type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return i.f(*i.first);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Binary Version
|
||||
template <>
|
||||
struct deref_impl<transform_view_iterator2_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
result_of::value_of<typename Iterator::first1_type>::type
|
||||
value1_type;
|
||||
typedef typename
|
||||
result_of::value_of<typename Iterator::first2_type>::type
|
||||
value2_type;
|
||||
|
||||
typedef detail::apply_transform_result<typename Iterator::transform_type> transform_type;
|
||||
typedef typename mpl::apply<transform_type, value1_type, value2_type>::type type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return i.f(*i.first1, *i.first2);
|
||||
}
|
||||
};
|
||||
}; }
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
Use, modification and distribution is subject to 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_DISTANCE_IMPL_13122005_2139)
|
||||
#define FUSION_DISTANCE_IMPL_13122005_2139
|
||||
|
||||
#include <boost/fusion/iterator/distance.hpp>
|
||||
|
||||
namespace boost { namespace fusion {
|
||||
|
||||
struct transform_view_iterator_tag;
|
||||
struct transform_view_iterator2_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct distance_impl;
|
||||
|
||||
// Unary Version
|
||||
template<>
|
||||
struct distance_impl<transform_view_iterator_tag>
|
||||
{
|
||||
template<typename First, typename Last>
|
||||
struct apply
|
||||
{
|
||||
typedef typename First::first_type first_type;
|
||||
typedef typename Last::first_type last_type;
|
||||
typedef typename result_of::distance<first_type, last_type>::type type;
|
||||
|
||||
static type
|
||||
call(First const& first, Last const& last)
|
||||
{
|
||||
return boost::fusion::distance(first.first, last.first);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Binary Version
|
||||
template<>
|
||||
struct distance_impl<transform_view_iterator2_tag>
|
||||
{
|
||||
template<typename First, typename Last>
|
||||
struct apply
|
||||
{
|
||||
typedef typename First::first1_type first1_type;
|
||||
typedef typename Last::first1_type last1_type;
|
||||
typedef typename result_of::distance<first1_type, last1_type>::type type;
|
||||
|
||||
static type
|
||||
call(First const& first, Last const& last)
|
||||
{
|
||||
return boost::fusion::distance(first.first1, last.first1);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -0,0 +1,69 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_1028)
|
||||
#define FUSION_END_IMPL_07162005_1028
|
||||
|
||||
#include <boost/fusion/sequence/view/transform_view/transform_view_fwd.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
template <typename First, typename F>
|
||||
struct transform_view_iterator;
|
||||
|
||||
template <typename First1, typename First2, typename F>
|
||||
struct transform_view_iterator2;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct end_impl;
|
||||
|
||||
// Unary Version
|
||||
template <>
|
||||
struct end_impl<transform_view_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Sequence::last_type last_type;
|
||||
typedef typename Sequence::transform_type transform_type;
|
||||
typedef transform_view_iterator<last_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Sequence& s)
|
||||
{
|
||||
return type(s.last(), s.f);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Binary Version
|
||||
template <>
|
||||
struct end_impl<transform_view2_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Sequence::last1_type last1_type;
|
||||
typedef typename Sequence::last2_type last2_type;
|
||||
typedef typename Sequence::transform_type transform_type;
|
||||
typedef transform_view_iterator2<last1_type, last2_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Sequence& s)
|
||||
{
|
||||
return type(s.last1(), s.last2(), s.f);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,75 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_1029)
|
||||
#define FUSION_NEXT_IMPL_07162005_1029
|
||||
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct transform_view_iterator_tag;
|
||||
struct transform_view_iterator2_tag;
|
||||
|
||||
template<typename First, typename F>
|
||||
struct transform_view_iterator;
|
||||
|
||||
template <typename First1, typename First2, typename F>
|
||||
struct transform_view_iterator2;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
// Unary Version
|
||||
template <>
|
||||
struct next_impl<transform_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::first_type first_type;
|
||||
typedef typename result_of::next<first_type>::type next_type;
|
||||
typedef typename Iterator::transform_type transform_type;
|
||||
typedef transform_view_iterator<next_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(fusion::next(i.first), i.f);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Binary Version
|
||||
template <>
|
||||
struct next_impl<transform_view_iterator2_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::first1_type first1_type;
|
||||
typedef typename Iterator::first2_type first2_type;
|
||||
typedef typename result_of::next<first1_type>::type next1_type;
|
||||
typedef typename result_of::next<first2_type>::type next2_type;
|
||||
typedef typename Iterator::transform_type transform_type;
|
||||
typedef transform_view_iterator2<next1_type, next2_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(fusion::next(i.first1), fusion::next(i.first2), i.f);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,74 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
Use, modification and distribution is subject to 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_PREV_IMPL_13122005_2110)
|
||||
#define FUSION_PREV_IMPL_13122005_2110
|
||||
|
||||
#include <boost/fusion/iterator/prior.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct transform_view_iterator_tag;
|
||||
struct transform_view_iterator2_tag;
|
||||
|
||||
template<typename First, typename F>
|
||||
struct transform_view_iterator;
|
||||
|
||||
template <typename First1, typename First2, typename F>
|
||||
struct transform_view_iterator2;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<typename Tag>
|
||||
struct prior_impl;
|
||||
|
||||
// Unary Version
|
||||
template<>
|
||||
struct prior_impl<transform_view_iterator_tag>
|
||||
{
|
||||
template<typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::first_type first_type;
|
||||
typedef typename result_of::prior<first_type>::type prior_type;
|
||||
typedef typename Iterator::transform_type transform_type;
|
||||
typedef transform_view_iterator<prior_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(fusion::prior(i.first), i.f);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Binary Version
|
||||
template<>
|
||||
struct prior_impl<transform_view_iterator2_tag>
|
||||
{
|
||||
template<typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::first1_type first1_type;
|
||||
typedef typename Iterator::first2_type first2_type;
|
||||
typedef typename result_of::prior<first1_type>::type prior1_type;
|
||||
typedef typename result_of::prior<first2_type>::type prior2_type;
|
||||
typedef typename Iterator::transform_type transform_type;
|
||||
typedef transform_view_iterator2<prior1_type, prior2_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(fusion::prior(i.first1), fusion::prior(i.first2), i.f);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -0,0 +1,64 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_OF_IMPL_07162005_1030)
|
||||
#define FUSION_VALUE_OF_IMPL_07162005_1030
|
||||
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/fusion/iterator/value_of.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/detail/apply_transform_result.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct transform_view_iterator_tag;
|
||||
struct transform_view_iterator2_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_of_impl;
|
||||
|
||||
// Unary Version
|
||||
template <>
|
||||
struct value_of_impl<transform_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
result_of::value_of<typename Iterator::first_type>::type
|
||||
value_type;
|
||||
|
||||
typedef detail::apply_transform_result<typename Iterator::transform_type> transform_type;
|
||||
typedef typename mpl::apply<transform_type, value_type>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
// Binary Version
|
||||
template <>
|
||||
struct value_of_impl<transform_view_iterator2_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
result_of::value_of<typename Iterator::first1_type>::type
|
||||
value1_type;
|
||||
typedef typename
|
||||
result_of::value_of<typename Iterator::first2_type>::type
|
||||
value2_type;
|
||||
|
||||
typedef detail::apply_transform_result<typename Iterator::transform_type> transform_type;
|
||||
typedef typename mpl::apply<transform_type, value1_type, value2_type>::type type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,95 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_TRANSFORM_VIEW_07162005_1037)
|
||||
#define FUSION_TRANSFORM_VIEW_07162005_1037
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/transform_view_iterator.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/transform_view_fwd.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/detail/begin_impl.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/detail/end_impl.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
struct transform_view_tag;
|
||||
struct transform_view2_tag;
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
// Binary Version
|
||||
template <typename Sequence1, typename Sequence2, typename F>
|
||||
struct transform_view : sequence_base<transform_view<Sequence1, Sequence2, F> >
|
||||
{
|
||||
BOOST_STATIC_ASSERT(result_of::size<Sequence1>::value == result_of::size<Sequence2>::value);
|
||||
typedef transform_view2_tag ftag;
|
||||
typedef fusion_sequence_tag tag; // this gets picked up by MPL
|
||||
typedef mpl::true_ is_view;
|
||||
|
||||
typedef typename traits::category_of<Sequence1>::type category1;
|
||||
typedef typename traits::category_of<Sequence2>::type category2;
|
||||
typedef typename result_of::begin<Sequence1>::type first1_type;
|
||||
typedef typename result_of::begin<Sequence2>::type first2_type;
|
||||
typedef typename result_of::end<Sequence1>::type last1_type;
|
||||
typedef typename result_of::end<Sequence2>::type last2_type;
|
||||
typedef typename result_of::size<Sequence1>::type size;
|
||||
typedef F transform_type;
|
||||
|
||||
transform_view(Sequence1& seq1, Sequence2& seq2, F const& binop)
|
||||
: f(binop)
|
||||
, seq1(seq1)
|
||||
, seq2(seq2)
|
||||
{}
|
||||
|
||||
first1_type first1() const { return fusion::begin(seq1); }
|
||||
first2_type first2() const { return fusion::begin(seq2); }
|
||||
last1_type last1() const { return fusion::end(seq1); }
|
||||
last2_type last2() const { return fusion::end(seq2); }
|
||||
|
||||
transform_type f;
|
||||
typename mpl::if_<traits::is_view<Sequence1>, Sequence1, Sequence1&>::type seq1;
|
||||
typename mpl::if_<traits::is_view<Sequence2>, Sequence2, Sequence2&>::type seq2;
|
||||
};
|
||||
|
||||
// Unary Version
|
||||
template <typename Sequence, typename F>
|
||||
struct transform_view<Sequence, F> : sequence_base<transform_view<Sequence, F> >
|
||||
{
|
||||
typedef transform_view_tag ftag;
|
||||
typedef fusion_sequence_tag tag; // this gets picked up by MPL
|
||||
typedef mpl::true_ is_view;
|
||||
|
||||
typedef typename traits::category_of<Sequence>::type category;
|
||||
typedef typename result_of::begin<Sequence>::type first_type;
|
||||
typedef typename result_of::end<Sequence>::type last_type;
|
||||
typedef typename result_of::size<Sequence>::type size;
|
||||
typedef F transform_type;
|
||||
|
||||
transform_view(Sequence& seq, F const& f)
|
||||
: seq(seq)
|
||||
, f(f)
|
||||
{}
|
||||
|
||||
first_type first() const { return fusion::begin(seq); }
|
||||
last_type last() const { return fusion::end(seq); }
|
||||
typename mpl::if_<traits::is_view<Sequence>, Sequence, Sequence&>::type seq;
|
||||
transform_type f;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_TRANSFORM_VIEW_FORWARD_01052006_1839)
|
||||
#define FUSION_TRANSFORM_VIEW_FORWARD_01052006_1839
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
struct transform_view_tag;
|
||||
struct transform_view2_tag;
|
||||
|
||||
template <typename A, typename B, typename C = void_>
|
||||
struct transform_view;
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,68 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
|
||||
Use, modification and distribution is subject to 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_TRANSFORM_VIEW_ITERATOR_07162005_1033)
|
||||
#define FUSION_TRANSFORM_VIEW_ITERATOR_07162005_1033
|
||||
|
||||
#include <boost/fusion/support/iterator_base.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/iterator/mpl/convert_iterator.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/detail/deref_impl.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/detail/next_impl.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/detail/prior_impl.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/detail/value_of_impl.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/detail/advance_impl.hpp>
|
||||
#include <boost/fusion/sequence/view/transform_view/detail/distance_impl.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
// Unary Version
|
||||
struct transform_view_iterator_tag;
|
||||
|
||||
template <typename First, typename F>
|
||||
struct transform_view_iterator
|
||||
: iterator_base<transform_view_iterator<First, F> >
|
||||
{
|
||||
typedef transform_view_iterator_tag ftag;
|
||||
typedef convert_iterator<First> converter;
|
||||
typedef typename converter::type first_type;
|
||||
typedef typename traits::category_of<first_type>::type category;
|
||||
typedef F transform_type;
|
||||
|
||||
transform_view_iterator(First const& first, F const& f)
|
||||
: first(converter::call(first)), f(f) {}
|
||||
|
||||
first_type first;
|
||||
transform_type f;
|
||||
};
|
||||
|
||||
// Binary Version
|
||||
struct transform_view_iterator2_tag;
|
||||
|
||||
template <typename First1, typename First2, typename F>
|
||||
struct transform_view_iterator2
|
||||
: iterator_base<transform_view_iterator2<First1, First2, F> >
|
||||
{
|
||||
typedef transform_view_iterator2_tag ftag;
|
||||
typedef convert_iterator<First1> converter1;
|
||||
typedef convert_iterator<First2> converter2;
|
||||
typedef typename converter1::type first1_type;
|
||||
typedef typename converter2::type first2_type;
|
||||
typedef typename traits::category_of<first1_type>::type category;
|
||||
typedef F transform_type;
|
||||
|
||||
transform_view_iterator2(First1 const& first1, First2 const& first2, F const& f)
|
||||
: first1(converter1::call(first1)), first2(converter2::call(first2)), f(f) {}
|
||||
|
||||
first1_type first1;
|
||||
first2_type first2;
|
||||
transform_type f;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user