joint_iter.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef BOOST_MPL_AUX_JOINT_ITER_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_JOINT_ITER_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2000-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <boost/mpl/next_prior.hpp>
  14. #include <boost/mpl/deref.hpp>
  15. #include <boost/mpl/iterator_tags.hpp>
  16. #include <boost/mpl/aux_/lambda_spec.hpp>
  17. #include <boost/mpl/aux_/config/ctps.hpp>
  18. #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  19. # include <boost/type_traits/is_same.hpp>
  20. #endif
  21. namespace boost { namespace mpl {
  22. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  23. template<
  24. typename Iterator1
  25. , typename LastIterator1
  26. , typename Iterator2
  27. >
  28. struct joint_iter
  29. {
  30. typedef Iterator1 base;
  31. typedef forward_iterator_tag category;
  32. };
  33. template<
  34. typename LastIterator1
  35. , typename Iterator2
  36. >
  37. struct joint_iter<LastIterator1,LastIterator1,Iterator2>
  38. {
  39. typedef Iterator2 base;
  40. typedef forward_iterator_tag category;
  41. };
  42. template< typename I1, typename L1, typename I2 >
  43. struct deref< joint_iter<I1,L1,I2> >
  44. {
  45. typedef typename joint_iter<I1,L1,I2>::base base_;
  46. typedef typename deref<base_>::type type;
  47. };
  48. template< typename I1, typename L1, typename I2 >
  49. struct next< joint_iter<I1,L1,I2> >
  50. {
  51. typedef joint_iter< typename mpl::next<I1>::type,L1,I2 > type;
  52. };
  53. template< typename L1, typename I2 >
  54. struct next< joint_iter<L1,L1,I2> >
  55. {
  56. typedef joint_iter< L1,L1,typename mpl::next<I2>::type > type;
  57. };
  58. #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
  59. template<
  60. typename Iterator1
  61. , typename LastIterator1
  62. , typename Iterator2
  63. >
  64. struct joint_iter;
  65. template< bool > struct joint_iter_impl
  66. {
  67. template< typename I1, typename L1, typename I2 > struct result_
  68. {
  69. typedef I1 base;
  70. typedef forward_iterator_tag category;
  71. typedef joint_iter< typename mpl::next<I1>::type,L1,I2 > next;
  72. typedef typename deref<I1>::type type;
  73. };
  74. };
  75. template<> struct joint_iter_impl<true>
  76. {
  77. template< typename I1, typename L1, typename I2 > struct result_
  78. {
  79. typedef I2 base;
  80. typedef forward_iterator_tag category;
  81. typedef joint_iter< L1,L1,typename mpl::next<I2>::type > next;
  82. typedef typename deref<I2>::type type;
  83. };
  84. };
  85. template<
  86. typename Iterator1
  87. , typename LastIterator1
  88. , typename Iterator2
  89. >
  90. struct joint_iter
  91. : joint_iter_impl< is_same<Iterator1,LastIterator1>::value >
  92. ::template result_<Iterator1,LastIterator1,Iterator2>
  93. {
  94. };
  95. #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
  96. BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(3, joint_iter)
  97. }}
  98. #endif // BOOST_MPL_AUX_JOINT_ITER_HPP_INCLUDED