tmp/tmplzl1migi/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Class template `ref_view` <a id="range.ref.view">[[range.ref.view]]</a>
|
| 2 |
+
|
| 3 |
+
`ref_view` is a `view` of the elements of some other `range`.
|
| 4 |
+
|
| 5 |
+
``` cpp
|
| 6 |
+
namespace std::ranges {
|
| 7 |
+
template<range R>
|
| 8 |
+
requires is_object_v<R>
|
| 9 |
+
class ref_view : public view_interface<ref_view<R>> {
|
| 10 |
+
private:
|
| 11 |
+
R* r_ = nullptr; // exposition only
|
| 12 |
+
public:
|
| 13 |
+
constexpr ref_view() noexcept = default;
|
| 14 |
+
|
| 15 |
+
template<not-same-as<ref_view> T>
|
| 16 |
+
requires see below
|
| 17 |
+
constexpr ref_view(T&& t);
|
| 18 |
+
|
| 19 |
+
constexpr R& base() const { return *r_; }
|
| 20 |
+
|
| 21 |
+
constexpr iterator_t<R> begin() const { return ranges::begin(*r_); }
|
| 22 |
+
constexpr sentinel_t<R> end() const { return ranges::end(*r_); }
|
| 23 |
+
|
| 24 |
+
constexpr bool empty() const
|
| 25 |
+
requires requires { ranges::empty(*r_); }
|
| 26 |
+
{ return ranges::empty(*r_); }
|
| 27 |
+
|
| 28 |
+
constexpr auto size() const requires sized_range<R>
|
| 29 |
+
{ return ranges::size(*r_); }
|
| 30 |
+
|
| 31 |
+
constexpr auto data() const requires contiguous_range<R>
|
| 32 |
+
{ return ranges::data(*r_); }
|
| 33 |
+
};
|
| 34 |
+
template<class R>
|
| 35 |
+
ref_view(R&) -> ref_view<R>;
|
| 36 |
+
}
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
``` cpp
|
| 40 |
+
template<not-same-as<ref_view> T>
|
| 41 |
+
requires see below
|
| 42 |
+
constexpr ref_view(T&& t);
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
*Remarks:* Let *`FUN`* denote the exposition-only functions
|
| 46 |
+
|
| 47 |
+
``` cpp
|
| 48 |
+
void FUN(R&);
|
| 49 |
+
void FUN(R&&) = delete;
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
The expression in the *requires-clause* is equivalent to
|
| 53 |
+
|
| 54 |
+
``` cpp
|
| 55 |
+
convertible_to<T, R&> && requires { FUN(declval<T>()); }
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
*Effects:* Initializes *r\_* with
|
| 59 |
+
`addressof(static_cast<R&>(std::forward<T>(t)))`.
|
| 60 |
+
|