[Development] QOptional
Иван Комиссаров
abbapoh at gmail.com
Thu Aug 21 09:34:17 CEST 2014
Иван Комиссаров
21 авг. 2014 г., в 2:10, Thiago Macieira <thiago.macieira at intel.com> написал(а):
> The optional-cast-to-boolean is a source of problems for the current
> std::optional. That hasn't been solved.
>
> QOptional<bool> opt1 = false;
> QOptional<int> opt2 = 0;
> if (opt1)
> // this is true!
> if (opt2)
> // this is false!
Hm, what? QOptional has no operator T and can't be converted to any value (bool or not) directly.
QOptional<bool> opt1 = false;
QOptional<int> opt2 = 0;
if (opt1)
// this is true!
if (*opt1)
// this is false!
if (opt2)
// this is true!
if (*opt2)
// this is false!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140821/80c9291f/attachment.html>
More information about the Development
mailing list