reverse_view.hpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !defined(FUSION_REVERSE_VIEW_07202005_0836)
  7. #define FUSION_REVERSE_VIEW_07202005_0836
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/support/detail/access.hpp>
  10. #include <boost/fusion/support/is_view.hpp>
  11. #include <boost/fusion/support/category_of.hpp>
  12. #include <boost/fusion/view/reverse_view/reverse_view_iterator.hpp>
  13. #include <boost/fusion/view/reverse_view/detail/begin_impl.hpp>
  14. #include <boost/fusion/view/reverse_view/detail/end_impl.hpp>
  15. #include <boost/fusion/view/reverse_view/detail/at_impl.hpp>
  16. #include <boost/fusion/view/reverse_view/detail/value_at_impl.hpp>
  17. #include <boost/fusion/support/sequence_base.hpp>
  18. #include <boost/fusion/sequence/intrinsic/begin.hpp>
  19. #include <boost/fusion/sequence/intrinsic/end.hpp>
  20. #include <boost/fusion/sequence/intrinsic/size.hpp>
  21. #include <boost/type_traits/is_base_of.hpp>
  22. #include <boost/static_assert.hpp>
  23. #include <boost/mpl/bool.hpp>
  24. #include <boost/mpl/eval_if.hpp>
  25. #include <boost/mpl/inherit.hpp>
  26. #include <boost/mpl/identity.hpp>
  27. #ifdef _MSC_VER
  28. # pragma warning(push)
  29. # pragma warning(disable: 4512) // assignment operator could not be generated.
  30. #endif
  31. namespace boost { namespace fusion
  32. {
  33. struct reverse_view_tag;
  34. struct fusion_sequence_tag;
  35. template <typename Sequence>
  36. struct reverse_view : sequence_base<reverse_view<Sequence> >
  37. {
  38. typedef reverse_view_tag fusion_tag;
  39. typedef fusion_sequence_tag tag; // this gets picked up by MPL
  40. typedef mpl::true_ is_view;
  41. typedef Sequence seq_type;
  42. typedef typename traits::category_of<Sequence>::type category;
  43. typedef typename result_of::begin<Sequence>::type first_type;
  44. typedef typename result_of::end<Sequence>::type last_type;
  45. typedef typename result_of::size<Sequence>::type size;
  46. BOOST_STATIC_ASSERT((
  47. is_base_of<
  48. bidirectional_traversal_tag
  49. , typename traits::category_of<first_type>::type>::value));
  50. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  51. reverse_view(Sequence& in_seq)
  52. : seq(in_seq)
  53. {}
  54. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  55. first_type first() const { return fusion::begin(seq); }
  56. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  57. last_type last() const { return fusion::end(seq); }
  58. typename mpl::if_<traits::is_view<Sequence>, Sequence, Sequence&>::type seq;
  59. };
  60. }}
  61. #ifdef _MSC_VER
  62. # pragma warning(pop)
  63. #endif
  64. #endif