segmented_end_impl.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*=============================================================================
  2. Copyright (c) 2011 Eric Niebler
  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(BOOST_FUSION_SEGMENTED_END_IMPL_HPP_INCLUDED)
  7. #define BOOST_FUSION_SEGMENTED_END_IMPL_HPP_INCLUDED
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/mpl/assert.hpp>
  10. #include <boost/type_traits/add_const.hpp>
  11. #include <boost/type_traits/remove_reference.hpp>
  12. #include <boost/fusion/sequence/intrinsic_fwd.hpp>
  13. #include <boost/fusion/container/list/cons_fwd.hpp>
  14. #include <boost/fusion/support/is_segmented.hpp>
  15. namespace boost { namespace fusion
  16. {
  17. template <typename First, typename Last>
  18. struct iterator_range;
  19. }}
  20. namespace boost { namespace fusion { namespace detail
  21. {
  22. //auto segmented_end_impl( seq, stack )
  23. //{
  24. // assert(is_segmented(seq));
  25. // auto it = end(segments(seq));
  26. // return cons(iterator_range(it, it), stack);
  27. //}
  28. template <typename Sequence, typename Stack>
  29. struct segmented_end_impl
  30. {
  31. BOOST_MPL_ASSERT((traits::is_segmented<Sequence>));
  32. typedef
  33. typename result_of::end<
  34. typename remove_reference<
  35. typename add_const<
  36. typename result_of::segments<Sequence>::type
  37. >::type
  38. >::type
  39. >::type
  40. end_type;
  41. typedef iterator_range<end_type, end_type> pair_type;
  42. typedef cons<pair_type, Stack> type;
  43. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  44. static pair_type make_pair(end_type end)
  45. {
  46. return pair_type(end, end);
  47. }
  48. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  49. static type call(Sequence & seq, Stack stack)
  50. {
  51. return type(
  52. make_pair(fusion::end(fusion::segments(seq))),
  53. stack);
  54. }
  55. };
  56. }}}
  57. #endif