[Development] Use of std::function in Qt API

Olivier Goffart olivier at woboq.com
Tue Mar 14 11:32:39 CET 2017

On Dienstag, 14. März 2017 10:33:44 CET Simon Hausmann wrote:
> Hi,
> I understand that there are limitations (to put it mildly) regarding the use
> of API from the C++ standard library in Qt API itself due to the inability
> to extend our binary compatibility promise. I'm curious though whether
> std::function falls under the same umbrella?

Yes, it does: the binary representation (including size), or the mangling is 
not guaranteed to be the same across stdlib implementations.

So here are the choice:

 1- Re-implement QFunction, with similar semantic as std::function.

 2- Lift the constraint that we can't use the stdlib in our ABI

 3- Do nothing and keep using awkward interface when we need callback.

#3 is, as usual, the easier (status quo) and will probably happen. #1 is a 
somewhat difficult task, but not that hard. We will just end up with a poor 
copy of std::function. #2 was always dismissed in the past, but I think it 
should be seriously considered.

(The same applies to std::unique_ptr, too)

> I understand that we permit the use of std::function in Windows specific API
> of QProcess, which may or may not be different. However I'm curious about
> this in the context of API that is intended to be fully cross-platform.

Actually, this is breaking the policy. Even on Windows, there are different 
std lib implementations. 


Woboq - Qt services and support - https://woboq.com - https://code.woboq.org

More information about the Development mailing list