HILA
Loading...
Searching...
No Matches
has_unary_minus.h
1#ifndef HAS_UNARY_MINUS_H
2#define HAS_UNARY_MINUS_H
3
4#include <type_traits>
5
6/////////////////////////////////////////////////////////////////////////////////////////////////
7/// This file implements "hila::has_unary_minus<T>::value" -conditional, which is false
8/// if the type T does not implement -T (unary -) operator, i.e.
9/// T T::operator-() const { .. }
10/// This is needed for antiperiodic b.c.
11/// Note that this gives false for unsigned type, whereas c++ allows -unsigned
12
13
14namespace hila {
15
16template <typename T, typename A = void>
17class has_unary_minus {
18 public:
19 static constexpr bool value = false;
20};
21
22template <typename T>
23class has_unary_minus<
24 T, typename std::enable_if_t<!std::is_unsigned<hila::arithmetic_type<T>>::value &&
25 hila::is_assignable<T &, decltype(-std::declval<T>())>::value>> {
26 public:
27 static constexpr bool value = true;
28};
29
30} // namespace hila
31
32#endif
Invert diagonal + const. matrix using Sherman-Morrison formula.
Definition array.h:920
std:swap() for Fields
Definition field.h:1847