replace_if.qbk 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. [/
  2. Copyright 2010 Neil Groves
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. /]
  6. [section:replace_if replace_if]
  7. [heading Prototype]
  8. ``
  9. template<class ForwardRange, class UnaryPredicate, class Value>
  10. ForwardRange& replace_if(ForwardRange& rng, UnaryPredicate pred, const Value& with_what);
  11. template<class ForwardRange, class UnaryPredicate, class Value>
  12. const ForwardRange& replace_if(const ForwardRange& rng, UnaryPredicate pred, const Value& with_what);
  13. ``
  14. [heading Description]
  15. `replace_if` replaces every element `x` in `rng` for which `pred(x) == true` with `with_what`. Returns a reference to `rng`.
  16. [heading Definition]
  17. Defined in the header file `boost/range/algorithm/replace_if.hpp`
  18. [heading Requirements]
  19. * `ForwardRange` is a model of the __forward_range__ Concept.
  20. * `ForwardRange` is mutable.
  21. * `UnaryPredicate` is a model of the `PredicateConcept`
  22. * `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type.
  23. * `Value` is convertible to `ForwardRange`'s value type.
  24. * `Value` is a model of the `AssignableConcept`.
  25. [heading Complexity]
  26. Linear. `replace_if` performs exactly `distance(rng)` applications of `pred`, and at most `distance(rng)` assignments.
  27. [endsect]