Fix test after fixing #1190

This commit is contained in:
Alexey Sokolov
2015-11-29 12:26:17 +00:00
parent 569f057561
commit bee266a08e
2 changed files with 98 additions and 29 deletions
+12 -2
View File
@@ -117,21 +117,23 @@ public:
#ifndef SWIG
template <typename M>
M& As() ZNC_LVREFQUAL {
static_assert(std::is_base_of<CMessage, M>{}, "Must be subclass of CMessage");
static_assert(sizeof(M) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
return static_cast<M&>(*this);
}
template <typename M>
const M& As() const ZNC_LVREFQUAL {
static_assert(std::is_base_of<CMessage, M>{}, "Must be subclass of CMessage");
static_assert(sizeof(M) == sizeof(CMessage), "No data members allowed in CMessage subclasses.");
return static_cast<const M&>(*this);
}
template <typename M>
template <typename M, typename = typename std::enable_if<std::is_base_of<CMessage, M>{}>::type>
operator M&() ZNC_LVREFQUAL {
return As<M>();
}
template <typename M>
template <typename M, typename = typename std::enable_if<std::is_base_of<CMessage, M>{}>::type>
operator const M&() const ZNC_LVREFQUAL {
return As<M>();
}
@@ -158,6 +160,14 @@ private:
bool m_bColon = false;
};
// For gtest
#ifdef GTEST_FAIL
template <typename M, typename = typename std::enable_if<std::is_base_of<CMessage, M>{}>::type>
inline ::std::ostream& operator<<(::std::ostream& os, const M& msg) {
return os << msg.ToString().Escape_n(CString::EDEBUG);
}
#endif
// The various CMessage subclasses are "mutable views" to the data held by CMessage.
// They provide convenient access to message type speficic attributes, but are not
// allowed to hold extra data of their own.