i have following code
#include <qdebug> //needed other stuff!! #include <qdatastream> class testclass { public: class subclass { public: qstring a; int b; /* //needed qdatastream not relevant generated error friend qdatastream& operator<<(qdatastream& os, subclass const& f) { os << f.a; os << f.b; return os; } friend qdatastream& operator>>(qdatastream& is, subclass& f) { >> f.a; >> f.b; return is; }*/ friend qdatastream& operator<< <subclass>(qdatastream&, qlist<subclass> const&); friend qdatastream& operator>> <subclass>(qdatastream&, qlist<subclass>&); }; }; compiling qt5.5 gives me following errors:
/usr/include/qt/qtcore/qflags.h:88: error: invalid application of 'sizeof' incomplete type 'testclass::subclass' q_static_assert_x((sizeof(enum) <= sizeof(int)), ^~~~~~~~~~~~ /usr/include/qt/qtcore/qtypetraits.h:478: error: 'testclass::subclass' incomplete type : integral_constant<bool, (t(0) < t(-1))> {}; ^ /usr/include/qt/qtcore/qdebug.h:279: in instantiation of template class 'qtprivate::isqenumhelper<qflags<testclass::subclass> >' requested here qtprivate::isqenumhelper<t>::value || qtprivate::isqenumhelper<qflags<t> >::value, ^ main.cpp:25: while substituting explicitly-specified template arguments function template 'operator<<' friend qdatastream& operator<< <subclass>(qdatastream&, qlist<subclass> const&); ^ the reason seems lie in following code of qdebug header file (qdebug.h:277):
template <class t> inline typename qtprivate::qenableif< qtprivate::isqenumhelper<t>::value || qtprivate::isqenumhelper<qflags<t> >::value, qdebug>::type operator<<(qdebug debug, const qflags<t> &flags) { //... } compiling qt5.4 works fine. right template function taken (qdatastream.h:241)
template <typename t> qdatastream& operator<<(qdatastream& s, const qlist<t>& l) { //... } questions:
- i know why template qdebug.h taken consideration. have ideas, answer appropriate links c++ standard , proper explanation nice.
- is there workaround or should submit bugreport qt?
the following (simplified code) generates same error.
#include <qdebug> //needed cause error class testclassa {}; class testclassb {}; template <typename t> testclassa& operator<<(testclassa& s, t& l) { q_unused(l) return s; } template testclassa& operator<< <testclassb>(testclassa& s, testclassb& l); bugreport opened at: https://bugreports.qt.io/browse/qtbug-47375
update: fixed it. fix included in qt 5.5.1
Comments
Post a Comment