Correct usage of volatile with std::atomic_ref<T>

  atomic, atomicreference, c++, mmap, volatile

I’m having trouble wrapping my head around the correct usage of std::atomic_ref<int> with volatile.

Naively there are three possibilities:

std::atomic_ref<volatile int> ref1;
volatile std::atomic_ref<int> ref2;
volatile std::atomic_ref<volatile int> ref3;

When and do we want to use each one? The use-case I’m interested in is MMIO.

Source: Windows Questions C++