[Development] How to include Standard Library headers from Qt ones?

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Sun Apr 16 19:51:46 CEST 2017

Il 16/04/2017 18:32, Corentin ha scritto:
> More on point:
>    * You don't actually need to include anything from the STL to
> implement std::hash.

You actually do: you need <functional> to see the primary template for
std::hash (otherwise you can't specialize it). Also, how to implement it
is another burden (see the other discussion).

>    * For qHash, maybe one or more qt_stl.h headers that would include
> the required stl headers. Forward declare when possible ( probably not
> often, sadly ). Compilations times may, for the time being, be an issue
> but I don't think Qt can or should work around them.
> I would also prefer a solution that is independent of the order of the
> includes.

A central STL header would work for qHash (apart from the huge
compilation times, as it'll need to include a *lot* of stuff), but I'm
scared that it would quickly become a maintenance nightmare.

It would be a bit dangerous for Q_DECLARE_TYPEINFO: such a declaration
might change the ABI for a type (so, for instance, if you include
qt_stl.h in a TU and forget in another TU and only include the STL
header, now the two TUs are binary incompatible between each other...).

Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4007 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170416/c4d8285f/attachment.bin>

More information about the Development mailing list