1 template<
typename T>
void IsNonZero(
const std::string& location,
2 const std::string& what,
9 template<
typename T>
void IsGreater(
const std::string& location,
10 const std::string& what,
13 const bool strictly) {
15 if ( !strictly && value < limit ) {
17 what+
" is strictly lower than "+std::to_string(limit),
19 }
else if ( strictly && value <= limit ) {
21 what+
" is lower or equal to "+std::to_string(limit),
26 template<
typename T>
void IsLower(
const std::string& location,
27 const std::string& what,
30 const bool strictly) {
32 if ( !strictly && value > limit ) {
34 what+
" is strictly greater than "+std::to_string(limit),
36 }
else if ( strictly && value >= limit ) {
38 what+
" is greater or equal to "+std::to_string(limit),
43 template<
typename T>
void IsEqual(
const std::string& location,
44 const std::string& what,
52 template<
typename T>
void IsNotEmpty(
const std::string& location,
53 const std::string& what,
54 const std::vector<T>& vector) {
60 template<
typename T>
void HasAtLeast(
const std::string& location,
61 const std::string& what,
62 const std::vector<T>& vector,
65 if ( vector.size() < n )
67 what+
" contains less than "+std::to_string(n)+
" elements",
71 template<
typename T>
void HasAtMost(
const std::string& location,
72 const std::string& what,
73 const std::vector<T>& vector,
76 if ( vector.size() > n )
78 what+
" contains more than "+std::to_string(n)+
" elements",
82 template<
typename T>
void SameSize(
const std::string& location,
83 const std::string& what,
84 const std::vector<T>& va,
85 const std::vector<T>& vb) {
87 if ( va.size() != vb.size() )
89 what+
" have different dimensions",
93 template<
typename T>
void SameSize(
const std::string& location,
94 const std::string& what,
95 const std::vector<std::vector<T>>& ma,
96 const std::vector<std::vector<T>>& mb) {
98 if ( ma.size() != mb.size() || ma[0].size() != mb[0].size() )
100 what+
" have different dimensions",
104 template<
typename T>
void Multiplicable(
const std::string& location,
105 const std::string& what,
106 const std::vector<std::vector<T>>& ma,
107 const std::vector<std::vector<T>>& mb) {
109 if ( ma[0].size() != mb.size() )
111 what+
" have incompatible dimensions to be multiplied",
115 template<
typename T>
void IsSquare(
const std::string& location,
116 const std::string& what,
117 const std::vector<std::vector<T>>& matrix) {
119 if ( matrix.size() != matrix[0].size() )
121 what+
" is not square",
125 template<
typename T>
void IsSymmetric(
const std::string& location,
126 const std::string& what,
127 const std::vector<std::vector<T>>& matrix) {
133 what+
" cannot be symmetric"+std::string(e.
what()),
138 for (i = 0; i < matrix.size(); i++)
139 for (j = i+1; j < matrix.size(); j++)
140 if ( matrix[i][j] != matrix[j][i] )
142 what+
" is not symmetric",
146 template<
typename T1,
typename T2>
void Contains(
const std::string& location,
147 const std::string& what,
148 const std::map<T1, T2>& map,
151 if ( map.find(key) == map.end() )
153 what+
" does not contain "+key,
const char * what() const
Return char buffer of message+" at "+location, memory remains owned by Exception. ...
Definition: Exception.hh:52
void IsSquare(const std::string &location, const std::string &what, const std::vector< std::vector< T >> &matrix)
Asserts that a matrix is square.
Definition: Assert.hh:116
Global exception object for all non-standard exceptions thrown by the code.
Definition: Exception.hh:30