iterator.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef BOOST_MPL_SET_AUX_ITERATOR_HPP_INCLUDED
  2. #define BOOST_MPL_SET_AUX_ITERATOR_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2003-2007
  4. // Copyright David Abrahams 2003-2004
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/mpl for documentation.
  11. // $Id$
  12. // $Date$
  13. // $Revision$
  14. #include <boost/mpl/set/aux_/set0.hpp>
  15. #include <boost/mpl/has_key.hpp>
  16. #include <boost/mpl/iterator_tags.hpp>
  17. #include <boost/mpl/next.hpp>
  18. #include <boost/mpl/eval_if.hpp>
  19. #include <boost/mpl/if.hpp>
  20. #include <boost/mpl/identity.hpp>
  21. #include <boost/mpl/aux_/config/ctps.hpp>
  22. namespace boost { namespace mpl {
  23. // used by 's_iter_get'
  24. template< typename Set, typename Tail > struct s_iter;
  25. template< typename Set, typename Tail > struct s_iter_get
  26. : eval_if<
  27. has_key< Set,typename Tail::item_type_ >
  28. , identity< s_iter<Set,Tail> >
  29. , next< s_iter<Set,Tail> >
  30. >
  31. {
  32. };
  33. template< typename Set, typename Tail > struct s_iter_impl
  34. {
  35. typedef Tail tail_;
  36. typedef forward_iterator_tag category;
  37. typedef typename Tail::item_type_ type;
  38. #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  39. typedef typename s_iter_get< Set,typename Tail::base >::type next;
  40. #endif
  41. };
  42. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  43. template< typename Set, typename Tail >
  44. struct next< s_iter<Set,Tail> >
  45. : s_iter_get< Set,typename Tail::base >
  46. {
  47. };
  48. template< typename Set >
  49. struct next< s_iter<Set,set0<> > >
  50. {
  51. typedef s_iter<Set,set0<> > type;
  52. };
  53. template< typename Set, typename Tail > struct s_iter
  54. : s_iter_impl<Set,Tail>
  55. {
  56. };
  57. template< typename Set > struct s_iter<Set, set0<> >
  58. {
  59. typedef forward_iterator_tag category;
  60. };
  61. #else
  62. template< typename Set >
  63. struct s_end_iter
  64. {
  65. typedef forward_iterator_tag category;
  66. typedef s_iter<Set,set0<> > next;
  67. };
  68. template< typename Set, typename Tail > struct s_iter
  69. : if_<
  70. is_same< Tail,set0<> >
  71. , s_end_iter<Set>
  72. , s_iter_impl<Set,Tail>
  73. >::type
  74. {
  75. };
  76. #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
  77. }}
  78. #endif // BOOST_MPL_SET_AUX_ITERATOR_HPP_INCLUDED