On Wed, Aug 24, 2016 at 1:57 PM, Eike Ziller <[email protected]> wrote: > - "optional<IEditor*> EditorManager::currentEditor() const” makes it explicit > that not having a current editor is a reasonable expectation, and that you > have to check this condition before doing anything with the potential IEditor > instance. > - On the other hand, IEditor instances without an IDocument are not allowed, > so if you are checking the return value of “IDocument *IEditor::document() > const”, you should do that only as part of a QTC_ASSERT/QTC_GUARD style > sanity check.
Playing devil's advocate here: what's the point of using an optional pointer? Pointers already have an optional value -- the null pointer constant. That seems totally redundant. Ideally one would use optional<IEditor&>, which doesn't compile for other reasons, but would have the semantics you describe. Cheers, -- Giuseppe D'Angelo _______________________________________________ Qt-creator mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/qt-creator
