[libc++][ranges] attempt to fix proxy iterator issues that cause Chromium to crash
The crash reported by Chrome v8 is related to sorting with v8::internal::AtomicSlot
According to https://chromium.googlesource.com/v8/v8/+/9bcb5eb590643db0c1f688fea316c7f1f4786a3c/src/objects/slots-atomic-inl.h
AtomicSlot is indeed a proxy iterator with a proxy type AtomicSlot::Reference
https://reviews.llvm.org/D130197 correctly spotted issues in __iter_move, but the fix does not fix the issue.
The reason is that AtomicSlot::operator* returns a prvalue Reference. After the fix in D130197, the return type
of __iter_move is Reference&&. But the rvalue reference is bond to the temporary value returned by operator*,
which will be dangling after __iter_move returns.
The idea of the fix in this change is borrowed from C++17's move_iterator
When underlying reference is a prvalue, we just return it by value.