
Martin Wille <mw8329@yahoo.com.au> writes:
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 7.1.5.1/2. 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.
How about the attached? The use of an inline function avoids the ODR violation, and the use of the detail::none_helper type with private constructors as the parameter ensures that noone can actually call the function, since they cannot construct a none_helper to pass. Likewise, they cannot define another function for use as none_t, since that function cannot construct the return value. Anthony -- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk