range/doc/reference/adaptors/ref_unwrapped.qbk
Robin Eckert 3225aaf82b add a new range adaptor boost::adaptors::ref_unwrapped
The new adaptor is like boost::adaptors::indirected, but for
std::reference_wrapper values (instead of pointer). It calls
.get() on every value and returns the result. It is useful for
range-based iteration of ranges of std::reference_wrapper (or
related) types.
2015-11-04 19:12:26 +01:00

33 lines
1.2 KiB
Plaintext

[/
Copyright 2015 Robin Eckert
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
/]
[section:ref_unwrapped ref_unwrapped]
[table
[[Syntax] [Code]]
[[Pipe] [`rng | boost::adaptors::ref_unwrapped`]]
[[Function] [`boost::adaptors::ref_unwrap(rng)`]]
]
This adaptor produces a range than applies `.get()` on all values in
the range. It is useful for iterating ranges of
`std::reference_wrapper` values or values using similar semantics.
The adaptor is C++11 (and above) only.
* [*Precondition:] The `value_type` of the range has a `.get() const`.
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `y.get()` where `y` is the corresponding element in the original range.
* [*Range Category:] __single_pass_range__
* [*Range Return Type:] `boost::unwrap_ref_range<decltype(rng)>`
* [*Returned Range Category:] The range category of `rng`.
[section:ref_unwrapped_example ref_unwrapped example]
[import ../../../test/adaptor_test/ref_unwrapped_example.cpp]
[ref_unwrapped_example]
[endsect]
This would produce the output `123`.
[endsect]