[Development] Improving toInt, toLong, etc.

Thiago Macieira thiago.macieira at intel.com
Tue Feb 4 16:16:20 CET 2014


Em ter 04 fev 2014, às 09:49:54, Robert Knight escreveu:
> > I'll write QOptional tomorrow or on Wednesday, after I've had the chance
> > to read the proposal to C++14 (that was dropped).
> 
> What would the plan for handling value access on unset options be?
> std::optional<>
> throws an exception. I initially did the same when implementing an
> Optional<T> class
> but ran into the kind of issue described here:
> http://stackoverflow.com/questions/13777446/ios-how-to-get-stack-trace-of-an
> -unhandled-stdexception qFatal() seems like the simple and obvious approach.

The idea was to silently return a default-constructed type.

That means QOptional would require a default-constructible and copyable type. 
It could never hold a QObject, for example, whereas std::optional could.
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358




More information about the Development mailing list