ampsci
c++ program for high-precision atomic structure calculations of single-valence systems
Loading...
Searching...
No Matches
Template.hpp
1#pragma once
2#include <type_traits>
3
4namespace qip {
5
7
31template <typename T, typename U = T>
33 friend bool operator!=(const T &lhs, const U &rhs) { return !(lhs == rhs); }
34 friend bool operator>(const T &lhs, const U &rhs) { return rhs < lhs; }
35 friend bool operator<=(const T &lhs, const U &rhs) { return !(lhs > rhs); }
36 friend bool operator>=(const T &lhs, const U &rhs) { return !(lhs < rhs); }
37};
38
40template <typename T>
42 friend T operator+(T lhs, const T &rhs) { return lhs += rhs; }
43 friend T operator-(T lhs, const T &rhs) { return lhs -= rhs; }
44 friend T operator*(T lhs, const T &rhs) { return lhs *= rhs; }
45 friend T operator/(T lhs, const T &rhs) { return lhs /= rhs; }
46};
47
49template <typename T, typename U>
51 friend T operator+(T lhs, const U &rhs) { return lhs += rhs; }
52 friend T operator-(T lhs, const U &rhs) { return lhs -= rhs; }
53 friend T operator*(T lhs, const U &rhs) { return lhs *= rhs; }
54 friend T operator/(T lhs, const U &rhs) { return lhs /= rhs; }
55 // Also define these symmetric ones
56 friend T operator+(const U &lhs, T rhs) { return rhs += lhs; }
57 friend T operator*(const U &lhs, T rhs) { return rhs *= lhs; }
58};
59
60} // namespace qip
Helper template for Arithmetic operations. Derive from this to provide +,-,*,/, given +=,...
Definition Template.hpp:50
Helper template for Arithmetic operations. Derive from this to provide +,-,*,/, given +=,...
Definition Template.hpp:41
Helper template for comparisons. Derive from this to provide !=,>,<=,>=, given == and <.
Definition Template.hpp:32
qip library: A collection of useful functions
Definition Array.hpp:9