> > >> <snip>, Pointers already have an optional value -- the null pointer > >> constant. <snip>
> <snip>, > Actually one could say that optional<T&> _is_ T* ;) > So basically to make a difference in the API we’d need to change all > pointers that are not optional to references. > IMHO, that is the correct approach. This is a well-understood C++ language feature: void foo(Dog&); // Instance required void foo(Dog*); // Instance optional This is one of my biggest complaints with "reference-langauges" like Java, and for any C++ API that does not appropriately use references: You *must* check for NULL when given a pointer. That's exhausting and error-prone, which is why references are better documentation and better convention when you don't want to do that. I have great concerns over APIs making ambitious use of optional<>. An aside: We are currently steeped in the tradition that "zero" is not a legal address, but that is (quickly) becoming not-true for process-containers, system-emulators and VMs, and new hardware (including new CPUs). That might be something about which we might want to start to consider (it's a paradigm change that likely also messes with our API decisions). --charley
_______________________________________________ Qt-creator mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/qt-creator
