[libcxx-commits] [libcxx] [libc++] Add `__exchange` as a C++11 utility (PR #187953)
Christopher Di Bella via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 23 10:53:09 PDT 2026
cjdb wrote:
> Looks like that we're unfortunately relying on assigning `void*` with a null pointer constant of an integer type.
Hopefully fixed.
> Also, it seems that most (if not all) touched cases are equivalent to `std::__exchange(obj, {})`, although it seems somehow undesired to use `{}`. Would it be better to invent a new function for this purpose? See also [P2226](https://wg21.link/p2226).
I can add `__take(obj)`, but `__exchange` is still a useful utility to have. I'm not really a fan of the name, though: I'd prefer `move_and_reset` or something similar, that describes its utility. Would you be okay with a name like that? Feel free to suggest something that's in a similar vein. I could also think about this for a day or two, and come up with a list of alternative names for us to choose from. Since it's an implementation detail, we can choose a different name to P2226.
https://github.com/llvm/llvm-project/pull/187953
More information about the libcxx-commits
mailing list