prior.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_PRIOR_05042005_1144)
  7. #define FUSION_PRIOR_05042005_1144
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/support/tag_of.hpp>
  10. namespace boost { namespace fusion
  11. {
  12. // Special tags:
  13. struct iterator_facade_tag; // iterator facade tag
  14. struct boost_array_iterator_tag; // boost::array iterator tag
  15. struct mpl_iterator_tag; // mpl sequence iterator tag
  16. struct std_pair_iterator_tag; // std::pair iterator tag
  17. namespace extension
  18. {
  19. template <typename Tag>
  20. struct prior_impl
  21. {
  22. template <typename Iterator>
  23. struct apply {};
  24. };
  25. template <>
  26. struct prior_impl<iterator_facade_tag>
  27. {
  28. template <typename Iterator>
  29. struct apply : Iterator::template prior<Iterator> {};
  30. };
  31. template <>
  32. struct prior_impl<boost_array_iterator_tag>;
  33. template <>
  34. struct prior_impl<mpl_iterator_tag>;
  35. template <>
  36. struct prior_impl<std_pair_iterator_tag>;
  37. }
  38. namespace result_of
  39. {
  40. template <typename Iterator>
  41. struct prior
  42. : extension::prior_impl<typename detail::tag_of<Iterator>::type>::
  43. template apply<Iterator>
  44. {};
  45. }
  46. template <typename Iterator>
  47. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  48. inline typename result_of::prior<Iterator>::type const
  49. prior(Iterator const& i)
  50. {
  51. return result_of::prior<Iterator>::call(i);
  52. }
  53. }}
  54. #endif