[Development] Updating holdover API from Qt 1 times
Kevin Kofler
kevin.kofler at chello.at
Tue Aug 20 03:25:15 CEST 2019
Sze Howe Koh wrote:
> 3) Pick one of the options above, but go one step further and use
> std::optional (C++17) instead of returning null objects. I imagine this
> should apply more broadly to the whole of Qt, not just the functions
> discussed here.
IMHO, std::optional conceptually makes sense only for types that are not
able to natively represent a null state. This is not the case for
implicitly-shared data objects, which have a natural native null state
(where the shared d pointer is null). So std::optional is redundant and
introduces an unwanted distinction between a null optional and a null
object. And it also means that at least a boolean flag is unnecessarily
added somewhere in memory.
Kevin Kofler
More information about the Development
mailing list