STL Static-Const Member Definitions
- by javery
How does the following work?
#include <limits>
int main()
{
const int* const foo = &std::numeric_limits<int> ::digits;
}
I was under the impression that in order to take an address of a static const-ant member we had to physically define it in some translation unit in order to please the linker. That said, after looking at the preprocessed code for this TU, I couldn't find an external definition for the digits member (or any other relevant members).
I tested this on two compilers (VC++ 10 and g++ 4.2.4) and got identical results (i.e., it works). Does the linker auto-magically link against an object file where this stuff is defined, or am I missing something obvious here?