adds intrinsics to support the concept of the underlying sequence

[SVN r37232]
This commit is contained in:
Tobias Schwinger
2007-03-19 19:03:41 +00:00
parent 324923acc2
commit 29a57477e0
3 changed files with 85 additions and 3 deletions

View File

@ -0,0 +1,44 @@
/*=============================================================================
Copyright (c) 2007 Tobias Schwinger
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_ITERATOR_RANGE_AT_IMPL_HPP_INCLUDED)
#define BOOST_FUSION_ITERATOR_RANGE_AT_IMPL_HPP_INCLUDED
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/deref.hpp>
namespace boost { namespace fusion
{
struct iterator_range_tag;
namespace extension
{
template <typename Tag>
struct at_impl;
template <>
struct at_impl<iterator_range_tag>
{
template <typename Seq, typename N>
struct apply
{
typedef typename Seq::begin_type begin_type;
typedef typename result_of::advance<begin_type,N>::type pos;
typedef typename result_of::deref<pos>::type type;
static type
call(Seq& s)
{
return * advance<N>(s.first);
}
};
};
}
}}
#endif

View File

@ -0,0 +1,38 @@
/*=============================================================================
Copyright (c) 2007 Tobias Schwinger
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_ITERATOR_RANGE_VALUE_AT_IMPL_HPP_INCLUDED)
#define BOOST_FUSION_ITERATOR_RANGE_VALUE_AT_IMPL_HPP_INCLUDED
#include <boost/fusion/iterator/advance.hpp>
#include <boost/fusion/iterator/value_of.hpp>
namespace boost { namespace fusion
{
struct iterator_range_tag;
namespace extension
{
template <typename Tag>
struct value_at_impl;
template <>
struct value_at_impl<iterator_range_tag>
{
template <typename Seq, typename N>
struct apply
{
typedef typename Seq::begin_type begin_type;
typedef typename result_of::advance<begin_type,N>::type pos;
typedef typename result_of::value_of<pos>::type type;
};
};
}
}}
#endif

View File

@ -12,6 +12,8 @@
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/sequence/view/iterator_range/detail/begin_impl.hpp>
#include <boost/fusion/sequence/view/iterator_range/detail/end_impl.hpp>
#include <boost/fusion/sequence/view/iterator_range/detail/at_impl.hpp>
#include <boost/fusion/sequence/view/iterator_range/detail/value_at_impl.hpp>
#include <boost/fusion/iterator/mpl/convert_iterator.hpp>
#include <boost/fusion/iterator/distance.hpp>
#include <boost/mpl/bool.hpp>
@ -31,9 +33,7 @@ namespace boost { namespace fusion
typedef typename result_of::distance<begin_type, end_type>::type size;
typedef mpl::true_ is_view;
typedef forward_traversal_tag category;
// typedef typename traits::category_of<begin_type>::type category;
// TODO: make it work - tosh
typedef typename traits::category_of<begin_type>::type category;
iterator_range(First const& first, Last const& last)
: first(convert_iterator<First>::call(first))