mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Log: use std::forward in operator<< and remove overload for const char*
There already is a template operator<< implemented, so far only for const references though. Changing this to perfectly forward the argument to the corresponding operator in the underlying std::ostringstring allows handling all the cases there, removing the need for a separate overload for const char*.
This commit is contained in:
parent
8d15e7ff9a
commit
ef0bc8366c
@ -27,6 +27,7 @@ template Log& Log::operator<<(const int&);
|
||||
template Log& Log::operator<<(const unsigned long&);
|
||||
template Log& Log::operator<<(const long&);
|
||||
template Log& Log::operator<<(const double&);
|
||||
template Log& Log::operator<<(const char*&);
|
||||
|
||||
REGISTER_TYPE(Logger);
|
||||
|
||||
@ -315,12 +316,3 @@ Log::~Log()
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
Log& Log::operator<<(const char *val)
|
||||
{
|
||||
if (!m_IsNoOp) {
|
||||
m_Buffer << val;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -119,17 +119,15 @@ public:
|
||||
~Log();
|
||||
|
||||
template<typename T>
|
||||
Log& operator<<(const T& val)
|
||||
Log& operator<<(T&& val)
|
||||
{
|
||||
if (!m_IsNoOp) {
|
||||
m_Buffer << val;
|
||||
m_Buffer << std::forward<T>(val);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Log& operator<<(const char *val);
|
||||
|
||||
private:
|
||||
LogSeverity m_Severity;
|
||||
String m_Facility;
|
||||
@ -146,6 +144,7 @@ extern template Log& Log::operator<<(const int&);
|
||||
extern template Log& Log::operator<<(const unsigned long&);
|
||||
extern template Log& Log::operator<<(const long&);
|
||||
extern template Log& Log::operator<<(const double&);
|
||||
extern template Log& Log::operator<<(const char*&);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user