Make some changes
This commit is contained in:
@@ -42,9 +42,12 @@
|
||||
* This macro calls the m_assert function which is a more informative
|
||||
* assertion function than the regular assert function from cassert.
|
||||
* */
|
||||
#define ASSERT(expr, msg) m_assert(expr, #expr, __FUNCTION__, __FILE__, \
|
||||
#define ASSERT(expr, msg) m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \
|
||||
__LINE__, msg)
|
||||
|
||||
#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
|
||||
|
||||
|
||||
/** Code stolen from https://github.com/anderkve/FYS3150
|
||||
* Header: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/include/utils.hpp
|
||||
* Source: https://github.com/anderkve/FYS3150/blob/master/code_examples/compilation_linking/example_1/src/utils.cpp
|
||||
@@ -105,4 +108,14 @@ void m_assert(bool expr,
|
||||
* */
|
||||
bool arma_vector_close_to(arma::vec &a, arma::vec &b, double tol=1e-8);
|
||||
|
||||
|
||||
static inline std::string methodName(const std::string& prettyFunction)
|
||||
{
|
||||
size_t colons = prettyFunction.find("::");
|
||||
size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
|
||||
size_t end = prettyFunction.rfind("(") - begin;
|
||||
|
||||
return prettyFunction.substr(begin,end) + "()";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user