make single_view random access

[SVN r72977]
This commit is contained in:
Eric Niebler
2011-07-08 19:42:35 +00:00
parent 0a54764a6a
commit f27ed26e44
276 changed files with 4030 additions and 4061 deletions

View File

@ -0,0 +1,47 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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_SINGLE_VIEW_ADVANCE_IMPL_JUL_07_2011_1348PM)
#define BOOST_FUSION_SINGLE_VIEW_ADVANCE_IMPL_JUL_07_2011_1348PM
#include <boost/mpl/plus.hpp>
namespace boost { namespace fusion
{
struct single_view_iterator_tag;
template <typename SingleView, typename Pos>
struct single_view_iterator;
namespace extension
{
template<typename Tag>
struct advance_impl;
template<>
struct advance_impl<single_view_iterator_tag>
{
template<typename Iterator, typename Dist>
struct apply
{
typedef single_view_iterator<
typename Iterator::single_view_type,
typename mpl::plus<typename Iterator::position, Dist>::type>
type;
static type
call(Iterator const& i)
{
return type(i.view);
}
};
};
}
}}
#endif

View File

@ -0,0 +1,44 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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_SINGLE_VIEW_AT_IMPL_JUL_07_2011_1348PM)
#define BOOST_FUSION_SINGLE_VIEW_AT_IMPL_JUL_07_2011_1348PM
#include <boost/mpl/int.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal_to.hpp>
namespace boost { namespace fusion
{
struct single_view_tag;
namespace extension
{
template<typename Tag>
struct at_impl;
template<>
struct at_impl<single_view_tag>
{
template<typename Sequence, typename N>
struct apply
{
BOOST_MPL_ASSERT((mpl::equal_to<N, mpl::int_<0> >));
typedef typename Sequence::value_type type;
static type
call(Sequence& seq)
{
return seq.val;
}
};
};
}
}}
#endif

View File

@ -1,17 +1,20 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2011 Eric Niebler
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_05052005_0305)
#define FUSION_BEGIN_IMPL_05052005_0305
#if !defined(BOOST_FUSION_SINGLE_VIEW_BEGIN_IMPL_05052005_0305)
#define BOOST_FUSION_SINGLE_VIEW_BEGIN_IMPL_05052005_0305
#include <boost/mpl/int.hpp>
namespace boost { namespace fusion
{
struct single_view_tag;
template <typename T>
template <typename SingleView, typename Pos>
struct single_view_iterator;
namespace extension
@ -25,12 +28,12 @@ namespace boost { namespace fusion
template <typename Sequence>
struct apply
{
typedef single_view_iterator<Sequence> type;
typedef single_view_iterator<Sequence, mpl::int_<0> > type;
static type
call(Sequence& s)
call(Sequence& seq)
{
return type(s);
return type(seq);
}
};
};

View File

@ -1,15 +1,16 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2011 Eric Niebler
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_05052005_0258)
#define FUSION_DEREF_IMPL_05052005_0258
#if !defined(BOOST_FUSION_SINGLE_VIEW_DEREF_IMPL_05052005_0258)
#define BOOST_FUSION_SINGLE_VIEW_DEREF_IMPL_05052005_0258
#include <boost/fusion/support/detail/access.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal_to.hpp>
namespace boost { namespace fusion
{
@ -26,12 +27,13 @@ namespace boost { namespace fusion
template <typename Iterator>
struct apply
{
BOOST_MPL_ASSERT((mpl::equal_to<typename Iterator::position, mpl::int_<0> >));
typedef typename Iterator::value_type type;
static type
call(Iterator const& i)
{
return i.val;
return i.view.val;
}
};
};

View File

@ -0,0 +1,43 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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_SINGLE_VIEW_DISTANCE_IMPL_JUL_07_2011_1348PM)
#define BOOST_FUSION_SINGLE_VIEW_DISTANCE_IMPL_JUL_07_2011_1348PM
#include <boost/mpl/minus.hpp>
namespace boost { namespace fusion
{
struct single_view_iterator_tag;
namespace extension
{
template<typename Tag>
struct distance_impl;
template<>
struct distance_impl<single_view_iterator_tag>
{
template<typename First, typename Last>
struct apply
: mpl::minus<typename Last::position, typename First::position>
{
typedef typename mpl::minus<typename Last::position,
typename First::position>::type type;
static type
call(First const& /*first*/, Last const& /*last*/)
{
return type();
}
};
};
}
}}
#endif

View File

@ -1,18 +1,21 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2011 Eric Niebler
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_05052005_0332)
#define FUSION_END_IMPL_05052005_0332
#if !defined(BOOST_FUSION_SINGLE_VIEW_END_IMPL_05052005_0332)
#define BOOST_FUSION_SINGLE_VIEW_END_IMPL_05052005_0332
#include <boost/mpl/int.hpp>
namespace boost { namespace fusion
{
struct single_view_tag;
template <typename T>
struct single_view_iterator_end;
template <typename SingleView, typename Pos>
struct single_view_iterator;
namespace extension
{
@ -25,12 +28,12 @@ namespace boost { namespace fusion
template <typename Sequence>
struct apply
{
typedef single_view_iterator_end<Sequence> type;
typedef single_view_iterator<Sequence, mpl::int_<1> > type;
static type
call(Sequence&)
call(Sequence& seq)
{
return type();
return type(seq);
}
};
};

View File

@ -0,0 +1,39 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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_SINGLE_VIEW_ITERATOR_JUL_07_2011_1348PM)
#define BOOST_FUSION_SINGLE_VIEW_ITERATOR_JUL_07_2011_1348PM
#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/add_const.hpp>
namespace boost { namespace fusion
{
struct single_view_iterator_tag;
namespace extension
{
template<typename Tag>
struct equal_to_impl;
template<>
struct equal_to_impl<single_view_iterator_tag>
{
template<typename It1, typename It2>
struct apply
: mpl::equal_to<typename It1::position, typename It2::position>
{
BOOST_MPL_ASSERT((is_same<typename add_const<typename It1::single_view_type>::type,
typename add_const<typename It2::single_view_type>::type>));
};
};
}
}}
#endif

View File

@ -1,20 +1,20 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2011 Eric Niebler
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_05052005_0331)
#define FUSION_NEXT_IMPL_05052005_0331
#if !defined(BOOST_FUSION_SINGLE_VIEW_NEXT_IMPL_05052005_0331)
#define BOOST_FUSION_SINGLE_VIEW_NEXT_IMPL_05052005_0331
#include <boost/mpl/next.hpp>
namespace boost { namespace fusion
{
struct single_view_iterator_tag;
template <typename SingleView>
struct single_view_iterator_end;
template <typename SingleView>
template <typename SingleView, typename Pos>
struct single_view_iterator;
namespace extension
@ -28,14 +28,15 @@ namespace boost { namespace fusion
template <typename Iterator>
struct apply
{
typedef single_view_iterator_end<
typename Iterator::single_view_type>
typedef single_view_iterator<
typename Iterator::single_view_type,
typename mpl::next<typename Iterator::position>::type>
type;
static type
call(Iterator)
call(Iterator const& i)
{
return type();
return type(i.view);
}
};
};

View File

@ -0,0 +1,46 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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_SINGLE_VIEW_PRIOR_IMPL_JUL_07_2011_1348PM)
#define BOOST_FUSION_SINGLE_VIEW_PRIOR_IMPL_JUL_07_2011_1348PM
#include <boost/mpl/prior.hpp>
namespace boost { namespace fusion
{
struct single_view_iterator_tag;
template <typename Sequence, typename Pos>
struct single_view_iterator;
namespace extension
{
template <typename Tag>
struct prior_impl;
template <>
struct prior_impl<single_view_iterator_tag>
{
template <typename Iterator>
struct apply
{
typedef single_view_iterator<
typename Iterator::single_view_type,
typename mpl::prior<typename Iterator::position>::type>
type;
static type
call(Iterator const& i)
{
return type(i.view);
}
};
};
}
}}
#endif

View File

@ -0,0 +1,33 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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_SINGLE_VIEW_SIZE_IMPL_JUL_07_2011_1348PM)
#define FUSION_SINGLE_VIEW_SIZE_IMPL_JUL_07_2011_1348PM
namespace boost { namespace fusion
{
struct single_view_tag;
namespace extension
{
template <typename Tag>
struct size_impl;
template <>
struct size_impl<single_view_tag>
{
template <typename Sequence>
struct apply
{
typedef mpl::int_<1> type;
};
};
}
}}
#endif

View File

@ -0,0 +1,39 @@
/*=============================================================================
Copyright (c) 2011 Eric Niebler
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_SINGLE_VIEW_VALUE_AT_IMPL_JUL_07_2011_1348PM)
#define BOOST_FUSION_SINGLE_VIEW_VALUE_AT_IMPL_JUL_07_2011_1348PM
#include <boost/mpl/int.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
namespace boost { namespace fusion
{
struct single_view_tag;
namespace extension
{
template<typename Tag>
struct value_at_impl;
template<>
struct value_at_impl<single_view_tag>
{
template<typename Sequence, typename N>
struct apply
{
BOOST_MPL_ASSERT((mpl::equal_to<N, mpl::int_<0> >));
typedef typename Sequence::value_type type;
};
};
}
}}
#endif

View File

@ -1,11 +1,16 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2011 Eric Niebler
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_05052005_0324)
#define FUSION_VALUE_IMPL_05052005_0324
#if !defined(BOOST_FUSION_SINGLE_VIEW_VALUE_OF_IMPL_05052005_0324)
#define BOOST_FUSION_SINGLE_VIEW_VALUE_OF_IMPL_05052005_0324
#include <boost/mpl/int.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal_to.hpp>
namespace boost { namespace fusion
{
@ -22,8 +27,8 @@ namespace boost { namespace fusion
template <typename Iterator>
struct apply
{
typedef typename Iterator::single_view_type single_view_type;
typedef typename single_view_type::value_type type;
BOOST_MPL_ASSERT((mpl::equal_to<typename Iterator::position, mpl::int_<0> >));
typedef typename Iterator::value_type type;
};
};
}

View File

@ -1,18 +1,22 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2011 Eric Niebler
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_SINGLE_VIEW_05052005_0335)
#define FUSION_SINGLE_VIEW_05052005_0335
#if !defined(BOOST_FUSION_SINGLE_VIEW_05052005_0335)
#define BOOST_FUSION_SINGLE_VIEW_05052005_0335
#include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/support/detail/as_fusion_element.hpp>
#include <boost/fusion/support/sequence_base.hpp>
#include <boost/fusion/view/single_view/single_view_iterator.hpp>
#include <boost/fusion/view/single_view/detail/at_impl.hpp>
#include <boost/fusion/view/single_view/detail/begin_impl.hpp>
#include <boost/fusion/view/single_view/detail/end_impl.hpp>
#include <boost/fusion/view/single_view/detail/size_impl.hpp>
#include <boost/fusion/view/single_view/detail/value_at_impl.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/int.hpp>
#include <boost/config.hpp>
@ -25,7 +29,7 @@
namespace boost { namespace fusion
{
struct single_view_tag;
struct forward_traversal_tag;
struct random_access_traversal_tag;
struct fusion_sequence_tag;
template <typename T>
@ -33,7 +37,7 @@ namespace boost { namespace fusion
{
typedef single_view_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef forward_traversal_tag category;
typedef random_access_traversal_tag category;
typedef mpl::true_ is_view;
typedef mpl::int_<1> size;
typedef T value_type;

View File

@ -1,16 +1,21 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2011 Eric Niebler
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_SINGLE_VIEW_ITERATOR_05052005_0340)
#define FUSION_SINGLE_VIEW_ITERATOR_05052005_0340
#if !defined(BOOST_FUSION_SINGLE_VIEW_ITERATOR_05052005_0340)
#define BOOST_FUSION_SINGLE_VIEW_ITERATOR_05052005_0340
#include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/support/iterator_base.hpp>
#include <boost/fusion/view/single_view/detail/deref_impl.hpp>
#include <boost/fusion/view/single_view/detail/next_impl.hpp>
#include <boost/fusion/view/single_view/detail/prior_impl.hpp>
#include <boost/fusion/view/single_view/detail/advance_impl.hpp>
#include <boost/fusion/view/single_view/detail/distance_impl.hpp>
#include <boost/fusion/view/single_view/detail/equal_to_impl.hpp>
#include <boost/fusion/view/single_view/detail/value_of_impl.hpp>
#include <boost/config.hpp>
@ -22,29 +27,25 @@
namespace boost { namespace fusion
{
struct single_view_iterator_tag;
struct forward_traversal_tag;
struct random_access_traversal_tag;
template <typename SingleView>
struct single_view_iterator_end
: iterator_base<single_view_iterator_end<SingleView> >
{
typedef single_view_iterator_tag fusion_tag;
typedef forward_traversal_tag category;
};
template <typename SingleView>
template <typename SingleView, typename Pos>
struct single_view_iterator
: iterator_base<single_view_iterator<SingleView> >
: iterator_base<single_view_iterator<SingleView, Pos> >
{
typedef single_view_iterator_tag fusion_tag;
typedef forward_traversal_tag category;
typedef random_access_traversal_tag category;
typedef typename SingleView::value_type value_type;
typedef Pos position;
typedef SingleView single_view_type;
explicit single_view_iterator(single_view_type const& view)
: val(view.val) {}
explicit single_view_iterator(single_view_type& in_view)
: view(in_view) {}
value_type val;
SingleView& view;
private:
single_view_iterator& operator=(single_view_iterator const&);
};
}}