mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-29 20:17:32 +02:00
corrected reverse_view
[SVN r58299]
This commit is contained in:
41
include/boost/fusion/view/reverse_view/detail/at_impl.hpp
Normal file
41
include/boost/fusion/view/reverse_view/detail/at_impl.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*=============================================================================
|
||||
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_AT_IMPL_HPP
|
||||
#define BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_AT_IMPL_HPP
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/mpl/minus.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace extension
|
||||
{
|
||||
template <typename>
|
||||
struct at_impl;
|
||||
|
||||
template <>
|
||||
struct at_impl<reverse_view_tag>
|
||||
{
|
||||
template <typename Seq, typename N>
|
||||
struct apply
|
||||
{
|
||||
typedef mpl::minus<typename Seq::size, mpl::int_<1>, N> real_n;
|
||||
|
||||
typedef typename
|
||||
result_of::at<typename Seq::seq_type, real_n>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Seq& seq)
|
||||
{
|
||||
return fusion::at<real_n>(seq.seq);
|
||||
}
|
||||
};
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
@ -0,0 +1,33 @@
|
||||
/*=============================================================================
|
||||
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_AT_IMPL_HPP
|
||||
#define BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_VALUE_AT_IMPL_HPP
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
|
||||
#include <boost/mpl/minus.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace extension
|
||||
{
|
||||
template <typename>
|
||||
struct value_at_impl;
|
||||
|
||||
template <>
|
||||
struct value_at_impl<reverse_view_tag>
|
||||
{
|
||||
template <typename Seq, typename N>
|
||||
struct apply
|
||||
: result_of::value_at<
|
||||
typename Seq::seq_type
|
||||
, mpl::minus<typename Seq::size, mpl::int_<1>, N>
|
||||
>
|
||||
{};
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
@ -13,6 +13,8 @@
|
||||
#include <boost/fusion/view/reverse_view/reverse_view_iterator.hpp>
|
||||
#include <boost/fusion/view/reverse_view/detail/begin_impl.hpp>
|
||||
#include <boost/fusion/view/reverse_view/detail/end_impl.hpp>
|
||||
#include <boost/fusion/view/reverse_view/detail/at_impl.hpp>
|
||||
#include <boost/fusion/view/reverse_view/detail/value_at_impl.hpp>
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
@ -28,7 +30,6 @@ namespace boost { namespace fusion
|
||||
{
|
||||
struct reverse_view_tag;
|
||||
struct fusion_sequence_tag;
|
||||
struct bidirectional_traversal_tag;
|
||||
|
||||
template <typename Sequence>
|
||||
struct reverse_view : sequence_base<reverse_view<Sequence> >
|
||||
@ -37,13 +38,8 @@ namespace boost { namespace fusion
|
||||
typedef fusion_sequence_tag tag; // this gets picked up by MPL
|
||||
typedef mpl::true_ is_view;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
traits::is_associative<Sequence>
|
||||
, mpl::inherit2<bidirectional_traversal_tag,associative_tag>
|
||||
, mpl::identity<bidirectional_traversal_tag>
|
||||
>::type
|
||||
category;
|
||||
typedef Sequence seq_type;
|
||||
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;
|
||||
|
Reference in New Issue
Block a user