~/talk

std:: exchange Idioms

Talkat CppCon 2017 · 2017-09-24..09-29· [rust]
slides:none on file

std::exchange is presented as a small C++14 utility that can be backported to C++11 and used to replace swap in common patterns, saving a move and an extra variable. Examples show replacing swap-and-iterate, using std::exchange in a lambda init-capture so the result RVOs into the capture, and a thread-safe idiom combining a lock_guard with the comma operator to swap out a container. Notes warn that using vector can force locking during iteration.

AI-written summary · about

  1. 0:00Intro
  2. 0:10What is exchange
  3. 0:40You dont need all the swap
  4. 1:05You dont need swap here
  5. 2:00Thread safety
  6. 3:11Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.