On Thursday 21 August 2014, Marc Mutz wrote: > On Thursday 21 August 2014 16:52:05 Thiago Macieira wrote: > > But I'd like QOptional<QString> o = QString() result in a null > > (disengaged) QOptional too. > > Too clever for a general optional class, IMO: > > QOptional<QString> qs = QString(); > QOptional<std::string> ss = std::string(); > > qs will be disengaged and ss will be engaged. Hard to explain in the docs. > Impossible to anticipate for new users of the class. Death row for template > code.
It would need to use some kind of inherently optional type trait. It could be true for QString but also for all pointer types and std::string. Btw, I would prefer if an optional<T> type did not have an implicit conversion to T. Like any wrapper like iterators or pointers, I think it would be better and safer to use a deference operator like operator* to access the content. `Allan _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
