iterator_facade.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_ITERATOR_FACADE_09252006_1011)
  7. #define FUSION_ITERATOR_FACADE_09252006_1011
  8. #include <boost/fusion/support/iterator_base.hpp>
  9. #include <boost/fusion/iterator/detail/advance.hpp>
  10. #include <boost/fusion/iterator/detail/distance.hpp>
  11. #include <boost/fusion/support/category_of.hpp>
  12. #include <boost/type_traits/is_same.hpp>
  13. #include <boost/mpl/assert.hpp>
  14. namespace boost { namespace fusion
  15. {
  16. struct iterator_facade_tag;
  17. template <typename Derived, typename Category>
  18. struct iterator_facade : iterator_base<Derived>
  19. {
  20. typedef iterator_facade_tag fusion_tag;
  21. typedef Derived derived_type;
  22. typedef Category category;
  23. // default implementation
  24. template <typename I1, typename I2>
  25. struct equal_to // default implementation
  26. : is_same<
  27. typename I1::derived_type
  28. , typename I2::derived_type
  29. >
  30. {};
  31. // default implementation
  32. template <typename Iterator, typename N>
  33. struct advance :
  34. mpl::if_c<
  35. (N::value > 0)
  36. , advance_detail::forward<Iterator, N::value>
  37. , advance_detail::backward<Iterator, N::value>
  38. >::type
  39. {
  40. BOOST_MPL_ASSERT_NOT((traits::is_random_access<Iterator>));
  41. };
  42. // default implementation
  43. template <typename First, typename Last>
  44. struct distance :
  45. distance_detail::linear_distance<First, Last>
  46. {};
  47. };
  48. }}
  49. #endif