Q:

Based only on the algorithm and argument names, describe the operation that the each of the following library algorithms performs

0

Based only on the algorithm and argument names, describe the operation that the each of the following library algorithms performs:

replace(beg, end, old_val, new_val);
replace_if(beg, end, pred, new_val);
replace_copy(beg, end, dest, old_val, new_val);
replace_copy_if(beg, end, dest, pred, new_val);

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

replace(beg, end, old_val, new_val);

Replace elements whose value is equal to `old_val` with `new_val` in iterator range `[beg, end)`.

replace_if(beg, end, pred, new_val);

Replace elements whose return value is nonzero when calling predicate `pred(val)` with `new_val` in iterator range `[beg, end)`.

replace_copy(beg, end, dest, old_val, new_val);

Copy elements in iterator range `[beg, end)` to iterator `dest`, and replace elements whose values are equal to `old_val` with `new_val`.

replace_copy_if(beg, end, dest, pred, new_val);

Copy elements in iterator range `[beg, end)` to iterator `dest`, and replace elements whose return value is nonzero when calling predicate `pred(val)` with `new_val`.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now