joint_view.hpp 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_JOINT_VIEW_07162005_0140)
  7. #define FUSION_JOINT_VIEW_07162005_0140
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/view/joint_view/joint_view_fwd.hpp>
  10. #include <boost/fusion/support/detail/access.hpp>
  11. #include <boost/fusion/support/is_view.hpp>
  12. #include <boost/fusion/sequence/intrinsic/begin.hpp>
  13. #include <boost/fusion/sequence/intrinsic/end.hpp>
  14. #include <boost/fusion/sequence/intrinsic/size.hpp>
  15. #include <boost/fusion/view/joint_view/joint_view_iterator.hpp>
  16. #include <boost/fusion/view/joint_view/detail/begin_impl.hpp>
  17. #include <boost/fusion/view/joint_view/detail/end_impl.hpp>
  18. #include <boost/fusion/support/sequence_base.hpp>
  19. #include <boost/mpl/if.hpp>
  20. #include <boost/mpl/plus.hpp>
  21. #include <boost/mpl/bool.hpp>
  22. #include <boost/mpl/eval_if.hpp>
  23. #include <boost/mpl/inherit.hpp>
  24. #include <boost/mpl/identity.hpp>
  25. #ifdef _MSC_VER
  26. # pragma warning(push)
  27. # pragma warning(disable: 4512) // assignment operator could not be generated.
  28. #endif
  29. namespace boost { namespace fusion
  30. {
  31. struct joint_view_tag;
  32. struct forward_traversal_tag;
  33. struct fusion_sequence_tag;
  34. template <typename Sequence1, typename Sequence2>
  35. struct joint_view : sequence_base<joint_view<Sequence1, Sequence2> >
  36. {
  37. typedef joint_view_tag fusion_tag;
  38. typedef fusion_sequence_tag tag; // this gets picked up by MPL
  39. typedef typename
  40. mpl::eval_if<
  41. mpl::and_<
  42. traits::is_associative<Sequence1>
  43. , traits::is_associative<Sequence2>
  44. >
  45. , mpl::inherit2<forward_traversal_tag,associative_tag>
  46. , mpl::identity<forward_traversal_tag>
  47. >::type
  48. category;
  49. typedef mpl::true_ is_view;
  50. typedef typename result_of::begin<Sequence1>::type first_type;
  51. typedef typename result_of::end<Sequence1>::type last_type;
  52. typedef typename result_of::begin<Sequence2>::type concat_type;
  53. typedef typename result_of::end<Sequence2>::type concat_last_type;
  54. typedef typename mpl::int_<
  55. result_of::size<Sequence1>::value + result_of::size<Sequence2>::value>
  56. size;
  57. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  58. joint_view(Sequence1& in_seq1, Sequence2& in_seq2)
  59. : seq1(in_seq1)
  60. , seq2(in_seq2)
  61. {}
  62. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  63. first_type first() const { return fusion::begin(seq1); }
  64. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  65. concat_type concat() const { return fusion::begin(seq2); }
  66. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  67. concat_last_type concat_last() const { return fusion::end(seq2); }
  68. private:
  69. typename mpl::if_<traits::is_view<Sequence1>, Sequence1, Sequence1&>::type seq1;
  70. typename mpl::if_<traits::is_view<Sequence2>, Sequence2, Sequence2&>::type seq2;
  71. };
  72. }}
  73. #ifdef _MSC_VER
  74. # pragma warning(pop)
  75. #endif
  76. #endif