>Out of curiosity: Why is this so? In principe, this does not sound imossible...
Names in Windows are namespaced into the DLL they come from. It isn't vector::vector, it's foo.dll!vector::vector. This is why, for example, local statics for functions in headers get one local static per DLL: when the function gets compiled into the different
DLLs they are not the same function in our model.
Moreover. the standard library on Windows is not an OS component; it is like any other library. We can be statically linked into as many DLLs as the user wants, and because no names are shared between DLLs they have no means of finding each other or similar.
The average Windows process has at least 3 standard libraries inside it (the kernel one, the OS user one, the one the program uses). This is why you can use brand new C++2023 features on Windows Vista from 2006, because in the "ordinary deployment model" you
bring your own CRT.
>And does this imply that other state in the standard library is then also not shared between different parts of a program?
It does. If you pass, for example, a std::vector between DLLs that use different CRTs you are in undefined behavior land. (Where, in particular, debug features will end up using different locks since they are globals (!!!))
The difference is that we consider std::atomic "like Core" and don't want to force customers using it to follow the usual "can't cross CRT boundaries" rules with it. Whereas atomic_ref only provides the usual guarantees: 2 DLLs that each statically link
the CRT and use atomic_ref between them do not actually get atomic access for non-lockfree atomics.
>All the C-runtimes could maybe depend on yet another DLL to host the lock table (I think atomic-ref does this?), but then you need to communicate to customers that they can't deploy applications using this variety of atomics unless they distribute
the extra DLLs, and put it in system locations.
We can't do that even if we wanted to because customers must be able to statically link. We take a dim view of applocal deployment sometimes but there are plenty of reasons customers can't use our redist installers sometimes, e.g. single binary xcopy deployment
required scenarios.