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

Marc Mutz marc.mutz at kdab.com
Tue Apr 25 12:59:03 CEST 2017


On Tuesday 14 March 2017 11:32:39 Olivier Goffart wrote:
> 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)

There's also #4: type-erase the std component.

Implemented in https://codereview.qt-project.org/192637

This commit, ladies and gentlemen, shows how we hurt ourselves for this policy 
of ours of keeping std types out of our ABI. And the issue in that commit is 
extremely subtle, too.

This is how we'd solve the issue with std types allowed:
https://codereview.qt-project.org/192656

What's holding us back?

Thanks,
Marc

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts



More information about the Development mailing list