14 #include <type_traits> 17 #ifdef MOOSE_KOKKOS_SCOPE 18 #define KOKKOS_SCALAR_FUNCTION KOKKOS_FUNCTION 20 #define KOKKOS_SCALAR_FUNCTION 29 template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
71 KOKKOS_SCALAR_FUNCTION
auto operator+() const -> decltype(+
std::declval<const T &>())
79 KOKKOS_SCALAR_FUNCTION
auto operator-() const -> decltype(-
std::declval<const T &>())
90 -> decltype(std::declval<T &>() +=
value, std::declval<Scalar &>())
100 template <
typename U>
102 -> decltype(std::declval<T &>() -=
value, std::declval<Scalar &>())
112 template <
typename U>
114 -> decltype(std::declval<T &>() *=
value, std::declval<Scalar &>())
124 template <
typename U>
126 -> decltype(std::declval<T &>() /=
value, std::declval<Scalar &>())
136 template <
typename U>
138 -> decltype(std::declval<T &>() %=
value, std::declval<Scalar &>())
149 template <
typename U = T>
150 auto operator++() -> decltype(++std::declval<U &>(), std::declval<Scalar &>())
160 template <
typename U = T>
169 template <
typename U = T>
170 auto operator--() -> decltype(--std::declval<U &>(), std::declval<Scalar &>())
180 template <
typename U = T>
191 template <
typename U>
193 -> decltype(std::declval<const T &>() +
value)
202 template <
typename U>
204 -> decltype(std::declval<const T &>() -
value)
213 template <
typename U>
215 -> decltype(std::declval<const T &>() *
value)
224 template <
typename U>
226 -> decltype(std::declval<const T &>() /
value)
235 template <
typename U>
237 -> decltype(std::declval<const T &>() %
value)
243 KOKKOS_SCALAR_FUNCTION
const T &
value()
const {
return static_cast<const T &
>(*this); }
251 template <
typename T,
typename Enable>
256 template <
typename T,
258 typename =
typename std::enable_if<!is_scalar<typename std::decay<T>::type>::value>::type>
259 KOKKOS_SCALAR_FUNCTION
auto 262 return left +
static_cast<const U &
>(right);
265 template <
typename T,
267 typename =
typename std::enable_if<!is_scalar<typename std::decay<T>::type>::value>::type>
268 KOKKOS_SCALAR_FUNCTION
auto 271 return left -
static_cast<const U &
>(right);
274 template <
typename T,
276 typename =
typename std::enable_if<!is_scalar<typename std::decay<T>::type>::value>::type>
277 KOKKOS_SCALAR_FUNCTION
auto 280 return left *
static_cast<const U &
>(right);
283 template <
typename T,
285 typename =
typename std::enable_if<!is_scalar<typename std::decay<T>::type>::value>::type>
286 KOKKOS_SCALAR_FUNCTION
auto 289 return left /
static_cast<const U &
>(right);
292 template <
typename T,
294 typename =
typename std::enable_if<!is_scalar<typename std::decay<T>::type>::value>::type>
295 KOKKOS_SCALAR_FUNCTION
auto 298 return left %
static_cast<const U &
>(right);
301 template <
typename T>
The Kokkos object that can hold the reference of a variable.
KOKKOS_SCALAR_FUNCTION auto operator+(const T &left, const Scalar< U > &right) -> decltype(left+static_cast< const U &>(right))
auto operator--() -> decltype(--std::declval< U &>(), std::declval< Scalar &>())
Prefix decrement the underlying host reference.
auto operator+=(const U &value) -> decltype(std::declval< T &>()+=value, std::declval< Scalar &>())
Add another value to the underlying host reference.
KOKKOS_SCALAR_FUNCTION auto operator+() const -> decltype(+std::declval< const T &>())
Get the positive value of the scalar.
KOKKOS_SCALAR_FUNCTION auto operator%(const T &left, const Scalar< U > &right) -> decltype(left % static_cast< const U &>(right))
auto operator%=(const U &value) -> decltype(std::declval< T &>() %=value, std::declval< Scalar &>())
Assign the remainder after division by another value to the underlying host reference.
auto operator++() -> decltype(++std::declval< U &>(), std::declval< Scalar &>())
Prefix increment the underlying host reference.
The Kokkos wrapper class that can hold the reference of an arithmetic scalar variable.
T & _reference
Writeable host reference of the variable.
KOKKOS_SCALAR_FUNCTION auto operator*(const T &left, const Scalar< U > &right) -> decltype(left *static_cast< const U &>(right))
auto operator*=(const U &value) -> decltype(std::declval< T &>() *=value, std::declval< Scalar &>())
Multiply the underlying host reference by another value.
Scalar(const Scalar &object)
Copy constructor.
KOKKOS_SCALAR_FUNCTION auto operator%(const U &value) const -> decltype(std::declval< const T &>() % value)
Get the remainder after division by another value.
KOKKOS_SCALAR_FUNCTION auto operator-(const U &value) const -> decltype(std::declval< const T &>() - value)
Subtract another value from this scalar.
auto operator--(int) -> decltype(std::declval< U &>() --)
Postfix decrement the underlying host reference.
KOKKOS_SCALAR_FUNCTION auto operator/(const T &left, const Scalar< U > &right) -> decltype(left/static_cast< const U &>(right))
auto operator++(int) -> decltype(std::declval< U &>()++)
Postfix increment the underlying host reference.
auto & operator=(const Scalar &value)
Assign a scalar value to the underlying host reference.
KOKKOS_SCALAR_FUNCTION auto operator-() const -> decltype(-std::declval< const T &>())
Get the negated value of the scalar.
The type trait that determines the default behavior of copy constructor and deepCopy() If this type t...
KOKKOS_SCALAR_FUNCTION const T & value() const
KOKKOS_SCALAR_FUNCTION auto operator*(const U &value) const -> decltype(std::declval< const T &>() *value)
Multiply this scalar by another value.
Scalar(T &value)
Constructor.
auto operator/=(const U &value) -> decltype(std::declval< T &>()/=value, std::declval< Scalar &>())
Divide the underlying host reference by another value.
KOKKOS_SCALAR_FUNCTION auto operator/(const U &value) const -> decltype(std::declval< const T &>()/value)
Divide this scalar by another value.
auto operator-=(const U &value) -> decltype(std::declval< T &>() -=value, std::declval< Scalar &>())
Subtract another value from the underlying host reference.
KOKKOS_SCALAR_FUNCTION auto operator+(const U &value) const -> decltype(std::declval< const T &>()+value)
Add another value to this scalar.
KOKKOS_SCALAR_FUNCTION auto operator-(const T &left, const Scalar< U > &right) -> decltype(left - static_cast< const U &>(right))
static constexpr bool value
auto operator=(const U &value) -> decltype(std::declval< T &>()=value, std::declval< Scalar &>())
Assign an arithmetic value to the underlying host reference.