Replace calls of PauseAndLock(do_lock=false) with new function RestoreStateAndUnlock for clarity. Callers of PauseAndLock ignored the return value when do_lock is false, so RestoreStateAndUnlock doesn't need to return anything.
std::copy
std::copy_n
std::find_if
std::ranges::find