[Development] QOptional

Thiago Macieira thiago.macieira at intel.com
Thu Aug 21 00:10:38 CEST 2014


On Wednesday 20 August 2014 21:27:44 Marc Mutz wrote:
> On Wednesday 20 August 2014 21:03:21 Иван Комиссаров wrote:
> > I'm not sure QOptional should mimick T*, not QVariant, but ok.
> 
>  QOptional<T> opt;
>  T *pt;
>  QVariant v;
> 
>  if (opt) ...
>  if (tp) ...
>  if (v) ... // ERROR
>  if (!opt) // operator! missing, btw
>  if (!tp)
>  if (!v)    // ERROR
> 
>  T t = *opt;
>  T t = *tp;
>  T t = *v;  // ERROR
> 
> Seems pretty clear to me it already models T*, not QVariant... :)

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!

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list