Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_mpl_for_each.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef SACADO_MPL_FOR_EACH_HPP
11 #define SACADO_MPL_FOR_EACH_HPP
12 
13 #include "Sacado_ConfigDefs.h"
14 
15 #include "Sacado_mpl_begin.hpp"
16 #include "Sacado_mpl_end.hpp"
17 #include "Sacado_mpl_next.hpp"
18 #include "Sacado_mpl_deref.hpp"
19 
20 namespace Sacado {
21 
22  namespace mpl {
23 
24  template <class Seq,
25  class Iter1 = typename mpl::begin<Seq>::type,
26  class Iter2 = typename mpl::end<Seq>::type>
27  struct for_each {
28  template <typename Op>
30  for_each(const Op& op) {
31  op(typename mpl::deref<Iter1>::type());
33  }
34  };
35 
36  template <class Seq, class Iter1>
37  struct for_each<Seq, Iter1, Iter1> {
38  template <typename Op>
40  for_each(const Op& op) {}
41  };
42 
43  // Same as for_each above, but without SACADO_INLINE_FUNCTION for functors
44  // that aren't meant to run inside kokkos kernels.
45  template <class Seq,
46  class Iter1 = typename mpl::begin<Seq>::type,
47  class Iter2 = typename mpl::end<Seq>::type>
49  template <typename Op>
50  for_each_no_kokkos(const Op& op) {
51  op(typename mpl::deref<Iter1>::type());
53  }
54  };
55 
56  template <class Seq, class Iter1>
57  struct for_each_no_kokkos<Seq, Iter1, Iter1> {
58  template <typename Op>
59  for_each_no_kokkos(const Op& /* op */) {}
60  };
61 
62  }
63 
64 }
65 
66 #endif // SACADO_MPL_FOR_EACH_HPP
void f()
SACADO_INLINE_FUNCTION for_each(const Op &op)
#define SACADO_INLINE_FUNCTION
SACADO_INLINE_FUNCTION for_each(const Op &op)