19 Nov
2014
19 Nov
'14
4:06 p.m.
On Wed, Nov 19, 2014 at 6:40 PM, Sylvester-Bradley, Gareth
Hi Andrey,
On Wed, Nov 19, 2014 at 3:27 PM, Andrey Semashev wrote:
Since none has internal linkage, it is translation unit-specific. Technically, this can cause ODR violations in some cases. To avoid that you can declare it like this:
struct none_t {};
template< typename T > struct singleton { static const T instance; }; template< typename T > const T singleton< T >::instance = T();
// Do we need... namespace {
const none_t& none = singleton< none_t >::instance;
} // ?
It seems so. I thought references don't have linkage but it looks like I was wrong. It doesn't add ODR violations though.