From 9c86b619a69d2a95d04bb4be0259d887b0a6a573 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Tue, 10 Nov 2015 19:40:34 -0800 Subject: [PATCH] Allow std::string ASSERT messages --- assert/assert.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assert/assert.h b/assert/assert.h index bcce66c9..52f1b868 100644 --- a/assert/assert.h +++ b/assert/assert.h @@ -15,19 +15,19 @@ namespace cpputils { namespace _assert { - inline std::string format(const char *expr, const char *message, const char *file, int line) { + inline std::string format(const char *expr, const std::string &message, const char *file, int line) { std::string result = std::string()+"Assertion ["+expr+"] failed in "+file+":"+std::to_string(line)+": "+message+"\n\n" + backtrace(); return result; } - inline void assert_fail_release [[noreturn]] (const char *expr, const char *message, const char *file, int line) { + inline void assert_fail_release [[noreturn]] (const char *expr, const std::string &message, const char *file, int line) { auto msg = format(expr, message, file, line); using namespace logging; LOG(ERROR) << msg; throw AssertFailed(msg); } - inline void assert_fail_debug [[noreturn]] (const char *expr, const char *message, const char *file, int line) { + inline void assert_fail_debug [[noreturn]] (const char *expr, const std::string &message, const char *file, int line) { using namespace logging; LOG(ERROR) << format(expr, message, file, line); abort();