## 24.4.4 Removal and Replacement Algorithms - `replace`

- `replace` takes a range, a value to search for, and a new value
- Replaces all occurrences of old value w/new (in range)
- `replace_if` uses predicate to find values to replace
- New value is fixed

  > `vector<int> a(10);
  > generate(a.begin(), a.end(), RandomInt(1, 5));
  > replace(a.begin(), a.end(), 3, 4);
  > replace_if(a.begin(), a.end(), is_even, 0);`

prev |top |next