From d763ad6319275e6c142a0917a81d537bb4817446 Mon Sep 17 00:00:00 2001 From: Evgenii Zhemchugov Date: Thu, 3 Aug 2023 15:00:23 +0100 Subject: [PATCH] Logging::operator<<: change argument type from T& to const T& Non-const references cannot be bound to functions results and literals, so the code ```C++ Logging log; try { throw std::runtime_error("message"); } catch (std::exception& e) { log << e.what() << '\n'; } ``` ends up calling `std::ostream::operator<<` both for `e.what()` and `'\n'` and produces nothing in the output. --- src/Logging/Logging.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Logging/Logging.h b/src/Logging/Logging.h index 1220078..9b9883f 100644 --- a/src/Logging/Logging.h +++ b/src/Logging/Logging.h @@ -189,7 +189,7 @@ class Logging: virtual public std::ostream { return *this; } - template Logging& operator<<(T &a){ + template Logging& operator<<(const T &a){ std::cout.rdbuf(buffer); std::cout<