Block-Structured AMR Software Framework
AMReX_Functional.H
Go to the documentation of this file.
1 #ifndef AMREX_FUNCTIONAL_H_
2 #define AMREX_FUNCTIONAL_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_GpuQualifiers.H>
6 
7 // Note that since C++14, std::functional class's operator() is constexpr.
8 // So we don't need to use the classes here except for Minimum and Maximum.
9 
10 namespace amrex {
11 
12 template <typename T>
13 struct Plus
14 {
15  constexpr T operator() (const T & lhs, const T & rhs) const
16  {
17  return lhs + rhs;
18  }
19 };
20 
21 template <typename T>
22 struct Minus
23 {
24  constexpr T operator() (const T & lhs, const T & rhs) const
25  {
26  return lhs - rhs;
27  }
28 };
29 
30 template <typename T>
31 struct Minimum
32 {
33  constexpr T operator() (const T & lhs, const T & rhs) const
34  {
35  return (lhs < rhs) ? lhs : rhs;
36  }
37 };
38 
39 template <typename T>
40 struct Maximum
41 {
42  constexpr T operator() (const T & lhs, const T & rhs) const
43  {
44  return (lhs > rhs) ? lhs : rhs;
45  }
46 };
47 
48 template <typename T>
49 struct LogicalAnd
50 {
51  constexpr T operator() (const T & lhs, const T & rhs) const
52  {
53  return lhs && rhs;
54  }
55 };
56 
57 template <typename T>
58 struct LogicalOr
59 {
60  constexpr T operator() (const T & lhs, const T & rhs) const
61  {
62  return lhs || rhs;
63  }
64 };
65 
66 template <typename T>
67 struct Multiplies
68 {
69  constexpr T operator() (const T & lhs, const T & rhs) const
70  {
71  return lhs * rhs;
72  }
73 };
74 
75 template <typename T>
76 struct Divides
77 {
78  constexpr T operator() (const T & lhs, const T & rhs) const
79  {
80  return lhs / rhs;
81  }
82 };
83 
84 }
85 
86 #endif
Definition: AMReX_Amr.cpp:49
Definition: AMReX_Functional.H:77
constexpr T operator()(const T &lhs, const T &rhs) const
Definition: AMReX_Functional.H:78
Definition: AMReX_Functional.H:50
constexpr T operator()(const T &lhs, const T &rhs) const
Definition: AMReX_Functional.H:51
Definition: AMReX_Functional.H:59
constexpr T operator()(const T &lhs, const T &rhs) const
Definition: AMReX_Functional.H:60
Definition: AMReX_Functional.H:41
constexpr T operator()(const T &lhs, const T &rhs) const
Definition: AMReX_Functional.H:42
Definition: AMReX_Functional.H:32
constexpr T operator()(const T &lhs, const T &rhs) const
Definition: AMReX_Functional.H:33
Definition: AMReX_Functional.H:23
constexpr T operator()(const T &lhs, const T &rhs) const
Definition: AMReX_Functional.H:24
Definition: AMReX_Functional.H:68
constexpr T operator()(const T &lhs, const T &rhs) const
Definition: AMReX_Functional.H:69
Definition: AMReX_Functional.H:14
constexpr T operator()(const T &lhs, const T &rhs) const
Definition: AMReX_Functional.H:15