replaced.qbk 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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:replaced replaced]
  7. [table
  8. [[Syntax] [Code]]
  9. [[Pipe] [`rng | boost::adaptors::replaced(old_value, new_value)`]]
  10. [[Function] [`boost::adaptors::replace(rng, old_value, new_value)`]]
  11. ]
  12. * [*Precondition:]
  13. * `new_value` is convertible to the `value_type` of the range.
  14. * `old_value` is convertible to the `value_type` of the range.
  15. * [*Postcondition:] For all elements `x` in the returned range, the value `x` is equal to the value of `(y == old_value) ? new_value : y` where `y` is the corresponding element in the original range.
  16. * [*Range Category:] __single_pass_range__
  17. * [*Range Return Type:] `boost::replaced_range<decltype(rng)>`
  18. * [*Returned Range Category:] The range category of `rng`.
  19. [section:replaced_example replaced example]
  20. [import ../../../test/adaptor_test/replaced_example.cpp]
  21. [replaced_example]
  22. [endsect]
  23. This would produce the output:
  24. ``
  25. 1,10,3,10,5,10,7,10,9,
  26. ``
  27. [endsect]