[Development] QOptional
Thiago Macieira
thiago.macieira at intel.com
Thu Aug 21 16:10:50 CEST 2014
On Thursday 21 August 2014 11:34:17 Иван Комиссаров wrote:
> Иван Комиссаров
>
> 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!
Sorry, then:
if (opt1 == false)
// ?
if (opt2 == false)
// ?
Does it have operator==(T)? Does it have operator RestrictedBool() / explicit
operator bool()?
Then there is a problem.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list