[Development] QOptional

Marc Mutz marc.mutz at kdab.com
Wed Aug 20 21:16:22 CEST 2014


On Wednesday 20 August 2014 21:03:21 Иван Комиссаров wrote:
> So, we construct null QOptional from invalid QVariant and  non-null
> QOptional from valid?

In current terms, yes. I like Thiago's implicit suggestion (in the change 
comments) to use isEmpty(), though (instead of isNull()).

  QOptional<T> QVariant::toOptionalValue()
  { return isValid() ? value<T>() : QOptional<T>() ; }

  QVariant QVariant::fromOptionalValue(const QOptional<T> &opt)
  { return opt ? fromValue(opt.value()) : QVariant() ; }



-- 
Qt Developer Days 2014 - October 6 - 8 at BCC, Berlin

Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions



More information about the Development mailing list