Op 26-10-2011 8:39, Frans Klaver schreef: > On Wed, Oct 26, 2011 at 8:31 AM,<[email protected]> wrote: > >> Consider this code: >> >> bool parseOk; >> if (str.toBool(&parseOk)) { >> if (parseOk) >> enableSuperFastRenderer(); >> } > I think that in most, if not all cases, the parseOk argument would or > even should be omitted (just like with QVariant): > > if (str.toBool()) { > enableSuperFastRenderer(); > } > > because the results will be exactly the same as your example. > >> then this: >> >> if (str == QLatin1String("true")) { >> enableSuperFastRenderer(); >> } >> >> which would you prefer? > I ask you the same question. IMHO, there is a big difference between a string that correctly converts to false, and one that can not be converted to a boolean. Do you really wish to make that difference invisible? That would not only break symetry with QString::toInt, it would lead to an IMHO useless method.
I agree with Jan Arve on this topic. You need to have verification that a conversion succeeded. André _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
