Boost logo

Boost :

From: Martin Wille (mw8329_at_[hidden])
Date: 2006-07-25 02:57:54

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?

none would have internal linkage according to So it wouldn't
violate the ODR. But a pointer to none from one translation unit would
differ from a pointer to none from a different TU.

> 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.

It would also avoid the pointer-to-none problem mentioned above, simply
because you can't create a pointer to an enumerator.

However, none_t instances of enumeration type would be implicitely
convertible to int, while the member pointer version of none_t isn't.


Send instant messages to your online friends

Boost list run by bdawes at, gregod at, cpdaniel at, john at