for_each.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  3. Copyright (c) 2007 Dan Marsden
  4. Copyright (c) 2018 Kohei Takahashi
  5. Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. ==============================================================================*/
  8. #if !defined(BOOST_FUSION_FOR_EACH_20070527_0943)
  9. #define BOOST_FUSION_FOR_EACH_20070527_0943
  10. #include <boost/fusion/support/config.hpp>
  11. #include <boost/fusion/algorithm/iteration/detail/for_each.hpp>
  12. #include <boost/fusion/algorithm/iteration/detail/segmented_for_each.hpp>
  13. #include <boost/fusion/support/is_segmented.hpp>
  14. #include <boost/fusion/support/is_sequence.hpp>
  15. #include <boost/core/enable_if.hpp>
  16. namespace boost { namespace fusion
  17. {
  18. namespace result_of
  19. {
  20. template <typename Sequence, typename F>
  21. struct for_each
  22. {
  23. typedef void type;
  24. };
  25. }
  26. template <typename Sequence, typename F>
  27. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  28. inline typename enable_if<traits::is_sequence<Sequence> >::type
  29. for_each(Sequence& seq, F f)
  30. {
  31. detail::for_each(seq, f, typename traits::is_segmented<Sequence>::type());
  32. }
  33. template <typename Sequence, typename F>
  34. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  35. inline typename enable_if<traits::is_sequence<Sequence> >::type
  36. for_each(Sequence const& seq, F f)
  37. {
  38. detail::for_each(seq, f, typename traits::is_segmented<Sequence>::type());
  39. }
  40. }}
  41. #endif