replace_copy, replace_copy_if, and tests