distance_impl.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2005-2006 Dan Marsden
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #if !defined(FUSION_DISTANCE_IMPL_13122005_2139)
  8. #define FUSION_DISTANCE_IMPL_13122005_2139
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/iterator/distance.hpp>
  11. namespace boost { namespace fusion {
  12. struct transform_view_iterator_tag;
  13. struct transform_view_iterator2_tag;
  14. namespace extension
  15. {
  16. template<typename Tag>
  17. struct distance_impl;
  18. // Unary Version
  19. template<>
  20. struct distance_impl<transform_view_iterator_tag>
  21. {
  22. template<typename First, typename Last>
  23. struct apply
  24. : result_of::distance<typename First::first_type, typename Last::first_type>
  25. {
  26. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  27. static
  28. typename result_of::distance<typename First::first_type, typename Last::first_type>::type
  29. call(First const& first, Last const& last)
  30. {
  31. return boost::fusion::distance(first.first, last.first);
  32. }
  33. };
  34. };
  35. // Binary Version
  36. template<>
  37. struct distance_impl<transform_view_iterator2_tag>
  38. {
  39. template<typename First, typename Last>
  40. struct apply
  41. : result_of::distance<typename First::first1_type, typename Last::first1_type>
  42. {
  43. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  44. static
  45. typename result_of::distance<typename First::first1_type, typename Last::first1_type>::type
  46. call(First const& first, Last const& last)
  47. {
  48. return boost::fusion::distance(first.first1, last.first1);
  49. }
  50. };
  51. };
  52. }
  53. }}
  54. #endif