Closed nigeltao closed 1 year ago
Addressing naming, I am more interested in naming consistency with std::mem::replace as this library is largely an implementation of std in terms of C++. Adding a comment is a great point, thanks.
Fair enough.
In case anyone else is initially confused, the std::exchange
that I referred to is in C++'s standard library. The std::mem::replace
that danakj referred to is in Rust's standard library.
https://github.com/chromium/subspace/blob/4273d92da22dd5f8fd9eef83aad76049be4df155/subspace/mem/replace.h#L33-L40
Is
sus::mem::replace
the same asstd::exchange
? Even if it's not exactly the same, for some C++ language lawyer reasons beyond my understanding (e.g. const-ness, move/copy constructors, rvalue references, whatever), perhaps renamingsus::mem::replace
tosus::mem::exchange
would make Subspace more familiar to a C++ programmer like me.Admittedly, being in
mem
, this might make it more confusable with the unrelatedstd::atomic<T>::exchange
.Even if you don't rename the function, it might still be worth mentioning
std::exchange
(and how it's similar or different) in thesus::mem::replace
doc comment.