pointer as non-type template argument

Consider classes Foo<&X> and Foo<&Y>, both with a static member int Bar. The linker must be able to tell whether your program has 1 or 2 Bar objects. Now consider that the linker is also the party most likely responsible for assigning values to &X and &Y.

Look at the Standard again. As it’s written, the compiler doesn’t need to communicate the actual address to the linker. Instead, it passes the id-expression. Linkers are already quite capable of determining whether two id-expression‘s are the same, even before assigning a numerical address to them.

Leave a Comment