
On 7/2/2011 4:44 AM, John Maddock wrote:
I mean things like
struct A { static const int value = 42; };
That works correctly in the library for gcc and VC++. Evidently the code that tests, which uses an expression of &A::value, is accepted by those compilers. Is it illegal to take the address of a static const data member in C++ ?
No, but you *may* need an out-of-line definition for the member "value" if the compiler considers the address to be "used": my guess is you're only using it within the context of another metafunction, so probably this should be OK.... probably ;)
Is there a relevant section in the C++ standard about this which you can cite offhand ? In my quick test of this I did not specify an out-of-line definition but then again I am not "using" the const value in any other way then to test against it.