[all-commits] [llvm/llvm-project] 8af8a6: [libc++] Add `__exchange` as a C++11 utility (#187...

Christopher Di Bella via All-commits all-commits at lists.llvm.org
Mon May 4 12:51:21 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8af8a60d544afaeac4834bb78f6b55bc890fb5fd
      https://github.com/llvm/llvm-project/commit/8af8a60d544afaeac4834bb78f6b55bc890fb5fd
  Author: Christopher Di Bella <cjdb at google.com>
  Date:   2026-05-05 (Tue, 05 May 2026)

  Changed paths:
    M libcxx/include/__hash_table
    M libcxx/include/__node_handle
    M libcxx/include/__thread/thread.h
    M libcxx/include/__utility/exchange.h
    M libcxx/include/__vector/vector_bool.h
    M libcxx/include/forward_list
    M libcxx/include/string
    M libcxx/test/std/ranges/range.adaptors/range.chunk.by/begin.pass.cpp

  Log Message:
  -----------
  [libc++] Add `__exchange` as a C++11 utility (#187953)

`std::exchange` is helpful for simplifying move operations because we
can couple the resetting component with the move operation. This both
halves the number of necessary lines for each move, and also ensures we
haven't forgotten to reset the moved-from object. Since `std::exchange`
is a C++14 feature, we'll need to use `__exchange` for anything that's
from C++11.

This commit also applies `std::__exchange` to a some trivial use-cases
to show its utility. Applying this project-wide requires a census over
all of our types. It's hoped that this will start a community-wide
clean-up that happens over time.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list