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

Smith Martin Martin.Smith at theqtcompany.com
Mon May 18 12:46:17 CEST 2015

You omitted that toInt(&ok) is required to test ok for null, which is not required if ok is a reference.


From: development-bounces+martin.smith=theqtcompany.com at qt-project.org <development-bounces+martin.smith=theqtcompany.com at qt-project.org> on behalf of Andreas Aardal Hanssen <andreas at hanssen.name>
Sent: Monday, May 18, 2015 12:10 PM
To: development
Subject: [Development] Fwd: QTextStream::readLine(0) is an ambiguous overload in 5.5

2015-05-18 11:54 GMT+02:00 Smith Martin <Martin.Smith at theqtcompany.com<mailto:Martin.Smith at theqtcompany.com>>:

When I'm reading code and I encounter a function call with parameters, if I am not familiar with that function, I look at its documentation. First I look at the signature. If it contains a non-const reference, I know the parameter can be modified. I read the function documentation to see if it is meant to be modified.

What is required inside the function if a pointer is used instead? Is the function required to test the pointer for nil and return in an error state or report an error? That doesn't happen with a reference.

Hi Martin :-).

IMO Qt's first level of helpfulness is its API. The code should be self-explaining and self-documenting if possible. Then, if you cannot figure out what a function does, Qt provides first class documentation. Which is why QList has append and prepend instead of push_back and push_front :-).

bool ok = false;
int foo = variable.toInt(ok); // need doc
int foo = variable.toInt(&ok); // dont need doc

Again though, this is procrastinating. Unless something significant has changed in C++ the last 10 years with regards to pointers and references I'd just continue sticking to what has always been the convention. Otherwise going through all Qt's api and changing it from pointers to references would be required. IMO.

Andreas Aardal Hanssen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150518/294f095e/attachment.html>

More information about the Development mailing list