[Development] r-value references in API (was: RFC: Proposal for a semi-radical change in Qt APIs taking strings)

Thiago Macieira thiago.macieira at intel.com
Thu Oct 15 17:57:50 CEST 2015


On Thursday 15 October 2015 07:34:30 Koehne Kai wrote:
> > -----Original Message-----
> > [...]
> > 
> > >BTW: functions storing a passed QString as-is should provide a
> > >QString&& overload, and that might be a good idea even when otherwise
> > >using QStringView only.
> > 
> > Yes, agree with this.
> 
> I guess this advice is not only for QString arguments though (from 5.7
> onwards). Which other types should get an && overload?
> 
> Does API exposed via Q_PROPERTY/ QML benefit from an r-value reference
> overloads, too?
> 
> I think it's a good idea to create some recommendations for 5.7 now, before
> everyone develops his own rules ...

I didn't address this in my reply to Marc...

This part of his proposal falls apart the moment that the API function calls 
something else to do the processing. Now you need to duplicate almost every 
code path from the user-facing API down to the processing of the data. And 
when the API has two data types, now the permutations explode...

rvalue refs only make sense for very simple sink functions. Not even most 
QString overloads would be able to do it.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list