refactor: Use assert instead of custom throw for invalid argument in TugUtils.hpp

This commit is contained in:
Max Lübke 2024-06-12 13:55:20 +02:00
parent 16fbefa9ed
commit 9aafb3e184

View File

@ -1,9 +1,6 @@
#ifndef TUGUTILS_H_ #pragma once
#define TUGUTILS_H_
#include <chrono> #include <cassert>
#include <stdexcept>
#include <string>
#define throw_invalid_argument(msg) \ #define throw_invalid_argument(msg) \
throw std::invalid_argument(std::string(__FILE__) + ":" + \ throw std::invalid_argument(std::string(__FILE__) + ":" + \
@ -24,6 +21,8 @@
duration.count(); \ duration.count(); \
}) })
#define tug_assert(expr, msg) assert((expr) && msg)
// calculates arithmetic or harmonic mean of alpha between two cells // calculates arithmetic or harmonic mean of alpha between two cells
template <typename T> template <typename T>
constexpr T calcAlphaIntercell(T alpha1, T alpha2, bool useHarmonic = true) { constexpr T calcAlphaIntercell(T alpha1, T alpha2, bool useHarmonic = true) {
@ -38,4 +37,3 @@ constexpr T calcAlphaIntercell(T alpha1, T alpha2, bool useHarmonic = true) {
return 0.5 * (alpha1 + alpha2); return 0.5 * (alpha1 + alpha2);
} }
} }
#endif // TUGUTILS_H_