Добрый день.
#include <iostream>
#include <thread>
#include <atomic>
using namespace std;
void f(int &ret)
{
ret = 43;
atomic_thread_fence(memory_order_release);
}
int main()
{
int ret;
thread t(f, ref(ret));
t.join();
atomic_thread_fence(memory_order_acquire);
cout << ret << endl;
}
P.S: код некорректен.