
Joe Gottman wrote:
In order to avoid having an unnamed namespace inside a header file, none.hpp has been rewritten as
namespace boost { none_t const none = ((none_t)0) ; } // namespace
But if two source files contain none.hpp won't this violate the one-definition rule? What's wrong with defining none_t and none as follows:
namespace boost { enum none_t {none = 0}; }
This allows us to have a unique value boost::none of type boost::none_t that can be included in any number of source files without violating the ODR.
Hi Joe, Sorry I couldn't respond earlier (having two jobs is killing me, although I can't say I don't enjoy it at the end of the month ;) As Martin said the problem with an enum is that it isn't type-safe, and in the particular case of optional<> that is very important because '0' is a "valid" value (so it's much more important than with a smart pointer) Fernando Cacciola