| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/// \file |
|
2
|
|
|
|
|
|
|
// Range v3 library |
|
3
|
|
|
|
|
|
|
// |
|
4
|
|
|
|
|
|
|
// Copyright Eric Niebler 2014-present |
|
5
|
|
|
|
|
|
|
// |
|
6
|
|
|
|
|
|
|
// Use, modification and distribution is subject to the |
|
7
|
|
|
|
|
|
|
// Boost Software License, Version 1.0. (See accompanying |
|
8
|
|
|
|
|
|
|
// file LICENSE_1_0.txt or copy at |
|
9
|
|
|
|
|
|
|
// http://www.boost.org/LICENSE_1_0.txt) |
|
10
|
|
|
|
|
|
|
// |
|
11
|
|
|
|
|
|
|
// Project home: https://github.com/ericniebler/range-v3 |
|
12
|
|
|
|
|
|
|
// |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#ifndef RANGES_V3_VIEW_VIEW_HPP |
|
15
|
|
|
|
|
|
|
#define RANGES_V3_VIEW_VIEW_HPP |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#include |
|
18
|
|
|
|
|
|
|
#include |
|
19
|
|
|
|
|
|
|
#include |
|
20
|
|
|
|
|
|
|
#include |
|
21
|
|
|
|
|
|
|
#include |
|
22
|
|
|
|
|
|
|
#include |
|
23
|
|
|
|
|
|
|
#include |
|
24
|
|
|
|
|
|
|
#include |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
namespace ranges |
|
27
|
|
|
|
|
|
|
{ |
|
28
|
|
|
|
|
|
|
inline namespace v3 |
|
29
|
|
|
|
|
|
|
{ |
|
30
|
|
|
|
|
|
|
/// \cond |
|
31
|
|
|
|
|
|
|
namespace detail |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
|
|
|
|
|
|
struct null_pipe |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
|
|
|
|
|
|
template |
|
36
|
|
|
|
|
|
|
void operator()(Rng &&) const |
|
37
|
|
|
|
|
|
|
{} |
|
38
|
|
|
|
|
|
|
}; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
/// \endcond |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
struct SimpleView |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
|
|
|
|
|
|
template |
|
45
|
|
|
|
|
|
|
auto requires_() -> decltype( |
|
46
|
|
|
|
|
|
|
concepts::valid_expr( |
|
47
|
|
|
|
|
|
|
concepts::model_of() && |
|
48
|
|
|
|
|
|
|
concepts::model_of() && |
|
49
|
|
|
|
|
|
|
concepts::model_of, iterator_t>() && |
|
50
|
|
|
|
|
|
|
concepts::model_of, sentinel_t>() |
|
51
|
|
|
|
|
|
|
)); |
|
52
|
|
|
|
|
|
|
}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
template |
|
55
|
|
|
|
|
|
|
constexpr bool simple_view() |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
|
|
|
|
|
|
return concepts::models::value; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
template |
|
61
|
|
|
|
|
|
|
using ViewableRange = meta::and_< |
|
62
|
|
|
|
|
|
|
Range, |
|
63
|
|
|
|
|
|
|
meta::or_, View>>>; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
namespace view |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
|
|
|
|
|
|
/// \addtogroup group-views |
|
68
|
|
|
|
|
|
|
/// @{ |
|
69
|
|
|
|
|
|
|
struct view_access |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
|
|
|
|
|
|
template |
|
72
|
|
|
|
|
|
|
struct impl |
|
73
|
|
|
|
|
|
|
{ |
|
74
|
|
|
|
|
|
|
template |
|
75
|
638
|
|
|
|
|
|
static auto bind(Ts &&...ts) |
|
76
|
638
|
|
|
|
|
|
RANGES_DECLTYPE_AUTO_RETURN |
|
77
|
|
|
|
|
|
|
( |
|
78
|
|
|
|
|
|
|
V::bind(static_cast(ts)...) |
|
79
|
|
|
|
|
|
|
) |
|
80
|
|
|
|
|
|
|
}; |
|
81
|
|
|
|
|
|
|
}; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
struct make_view_fn |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
|
|
|
|
|
|
template |
|
86
|
638
|
|
|
|
|
|
view operator()(Fun fun) const |
|
87
|
|
|
|
|
|
|
{ |
|
88
|
638
|
50
|
|
|
|
|
return {std::move(fun)}; |
|
|
|
50
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
}; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
/// \ingroup group-views |
|
93
|
|
|
|
|
|
|
/// \sa make_view_fn |
|
94
|
|
|
|
|
|
|
RANGES_INLINE_VARIABLE(make_view_fn, make_view) |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
template |
|
97
|
|
|
|
|
|
|
struct view : pipeable> |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
|
|
|
|
|
|
private: |
|
100
|
|
|
|
|
|
|
View view_; |
|
101
|
|
|
|
|
|
|
friend pipeable_access; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
template |
|
104
|
|
|
|
|
|
|
using ViewConcept = meta::and_, Invocable>; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
// Piping requires range arguments or lvalue containers. |
|
107
|
|
|
|
|
|
|
template
|
|
108
|
|
|
|
|
|
|
CONCEPT_REQUIRES_(ViewConcept())> |
|
109
|
638
|
|
|
|
|
|
static auto pipe(Rng && rng, Vw && v) |
|
110
|
638
|
|
|
|
|
|
RANGES_DECLTYPE_AUTO_RETURN |
|
111
|
|
|
|
|
|
|
( |
|
112
|
|
|
|
|
|
|
v.view_(static_cast(rng)) |
|
113
|
|
|
|
|
|
|
) |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#ifndef RANGES_DOXYGEN_INVOKED |
|
116
|
|
|
|
|
|
|
// For better error messages: |
|
117
|
|
|
|
|
|
|
template
|
|
118
|
|
|
|
|
|
|
CONCEPT_REQUIRES_(!ViewConcept())> |
|
119
|
|
|
|
|
|
|
static void pipe(Rng &&, Vw &&) |
|
120
|
|
|
|
|
|
|
{ |
|
121
|
|
|
|
|
|
|
CONCEPT_ASSERT_MSG(Range(), |
|
122
|
|
|
|
|
|
|
"The type Rng must be a model of the Range concept."); |
|
123
|
|
|
|
|
|
|
// BUGBUG This isn't a very helpful message. This is probably the wrong place |
|
124
|
|
|
|
|
|
|
// to put this check: |
|
125
|
|
|
|
|
|
|
CONCEPT_ASSERT_MSG(Invocable(), |
|
126
|
|
|
|
|
|
|
"This view is not callable with this range type."); |
|
127
|
|
|
|
|
|
|
static_assert(ranges::View() || std::is_lvalue_reference(), |
|
128
|
|
|
|
|
|
|
"You can't pipe an rvalue container into a view. First, save the container into " |
|
129
|
|
|
|
|
|
|
"a named variable, and then pipe it to the view."); |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
#endif |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
public: |
|
134
|
|
|
|
|
|
|
view() = default; |
|
135
|
638
|
|
|
|
|
|
view(View a) |
|
136
|
638
|
|
|
|
|
|
: view_(std::move(a)) |
|
137
|
638
|
|
|
|
|
|
{} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
// Calling directly requires View arguments or lvalue containers. |
|
140
|
|
|
|
|
|
|
template
|
|
141
|
|
|
|
|
|
|
CONCEPT_REQUIRES_(ViewConcept())> |
|
142
|
|
|
|
|
|
|
auto operator()(Rng && rng, Rest &&... rest) const |
|
143
|
|
|
|
|
|
|
RANGES_DECLTYPE_AUTO_RETURN |
|
144
|
|
|
|
|
|
|
( |
|
145
|
|
|
|
|
|
|
view_(static_cast(rng), static_cast(rest)...) |
|
146
|
|
|
|
|
|
|
) |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
// Currying overload. |
|
149
|
|
|
|
|
|
|
template |
|
150
|
638
|
|
|
|
|
|
auto operator()(Ts &&... ts) const |
|
151
|
638
|
50
|
|
|
|
|
RANGES_DECLTYPE_AUTO_RETURN |
|
|
|
50
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
( |
|
153
|
|
|
|
|
|
|
make_view(view_access::impl::bind(view_, |
|
154
|
|
|
|
|
|
|
static_cast(ts)...)) |
|
155
|
|
|
|
|
|
|
) |
|
156
|
|
|
|
|
|
|
}; |
|
157
|
|
|
|
|
|
|
/// \endcond |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
#endif |