Either I\'m very tired or something weird is happening that I\'m not aware of, because the code below is resulting in undefined symbols for Foo::A and Foo::B when li
There are good answers here, but one additional thing to note is that the parameters of std::min() are references, which is what requires the addresses of the passed in variables, and since those variables don't make it to the object file for the compilation unit, the linker cannot resolve their addresses.
You are probably getting this in an non-optimized build, correct?
I bet that you won't get this with gcc if you enable optimizations. The call to std::min() will get inlined and the references will go away.
Also, if you were to assign Foo::A and Foo::B to two local variables right before the call to std::min(), this issue would also go away.
This isn't ideal, but if you don't own the code that defines the variables that are causing you this issue, then this is something you can consider.