
* Use nullptr instead of boost::none? - this will make some uses of optional pointers harder, but will make usage more clear in other cases.
I don't think nullptr is a good choice here because of the complications you mentioned. Actually, I would prefer traditional clear() and empty() methods for clearing and testing for value presence. The operator safe_bool() and operator!() may also be present in the interface for brevity in conditional expressions.
Interesting. It looks like optional can be seen as a special container with the maximum size of 1, and then functions like clear() or empty() come as natural. On the other hand it can be seen as a pointer-like entity with value semantics, and then functions like reset() and literal nullptr come as natural. I withdraw my suggestion to use nullptr. Function reset() would be a better choice. I also find reset() preferable to clear() because reset can be extended to accept parameters and the name does not become confusing; similarly to unique_ptr::reset(). Also, if someone likes the assignment-of-"none" syntax, in C++11 there will be a similar syntax available: std::tr2::optional<T> op = {}; op = {}; Interestingly, boost::optional did have a reset function (now deprecated) which was replaced with boost::none assignment. I wonder what was the reason for this replacement. Regards, &rzej