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).

Thanks,
Marc

-- 
Marc Mutz <[email protected]> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to