void push(T const& data)
{
node * const new_node = new node(data);
new_node->next = head.load();
while(!head.compare_exchange_weak(new_node->next, new_node,
std::memory_order::memory_order_release, std::memory_order::memory_order_relaxed));
}
How above code guarantees that if two threads start push at the same time and come to compare_exchange_weak at the same time, and first thread changes value of head, second one can see new head value?