[Development] QTextStream::readLine(0) is an ambiguous overload in 5.5

Simon Hausmann simon.hausmann at theqtcompany.com
Mon May 18 09:15:01 CEST 2015


On Sunday, May 17, 2015 12:21:35 PM Thiago Macieira wrote:
> On Sunday 17 May 2015 22:17:04 Marc Mutz wrote:
> > On Sunday 17 May 2015 15:19:49 Giuseppe D'Angelo wrote:
> > > It would solve, but Qt APIs use pointers instead of references for
> > > out-arguments (and that's a very good code policy).
> > 
> > *Any* form of out parameter is bad code policy. Much better in virtually
> > all cases to return multiple values in a small struct.
> > 
> > In the case at hand, the idea is probably to reuse the capacity of the
> > passed QString, so returning a struct while still allowing reuse of the
> > capacity requires C++11 (taking a QString&& to avoid a refcount > 1, which
> > incidentally shows how poor pointer parameter semantics really are).
> > 
> > I believe it was Sean Parent who in one of his talks showed how capacity-
> > preserving file reading should be implemented (iirc, by keeping the string
> > as a member of an object and handing it out as a reference).
> 
> Since we're not going to implement that, I suggest renaming the function to
> "readLineInto" to solve the ambiguity.

I think that's a good idea.


Simon



More information about the Development mailing list