On Monday 26 September 2016 10:11:09 Ulf Hermann wrote: > This doesn't change the implicit conversion problem that Marc mentioned, > but at the moment I don't quite see a way to fix it without removing a lot > of convenience for the user (that is, have the user specify the exact > intended type for each serialization operation).
The solution is to have just one (templated) op<</op>> and (partially) specialise a struct that contains a static function (or a function call operator). This is how std::hash works (except it lacks the convenience function so you have to be explicit about the type), and why it's not susceptible to problems such a qHash(badly-designed smart-pointer) invoking qHash(bool) (if we had qHash(bool), which we don't have, for precisely that reason). Another solution is to write every op<</op>> as a constrained template, but that is decidedly not user-friendly (where user here is the user that extends op<</>> to her own types). Thanks, Marc -- Marc Mutz <[email protected]> | Senior Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company Tel: +49-30-521325470 KDAB - Qt, C++ and OpenGL Experts _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
