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
|
|
|
|
|
|
|
#ifndef RANGES_V3_VIEW_ALL_HPP |
14
|
|
|
|
|
|
|
#define RANGES_V3_VIEW_ALL_HPP |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#include |
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
|
|
|
|
|
|
|
/// \addtogroup group-views |
31
|
|
|
|
|
|
|
/// @{ |
32
|
|
|
|
|
|
|
namespace view |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
struct all_fn : pipeable |
35
|
|
|
|
|
|
|
{ |
36
|
|
|
|
|
|
|
private: |
37
|
|
|
|
|
|
|
template |
38
|
|
|
|
|
|
|
static iterator_range, sentinel_t> |
39
|
|
|
|
|
|
|
from_container(T & t, concepts::Range*, concepts::Sentinel*) |
40
|
|
|
|
|
|
|
{ |
41
|
|
|
|
|
|
|
return {begin(t), end(t)}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
template |
45
|
|
|
|
|
|
|
static sized_iterator_range, sentinel_t> |
46
|
|
|
|
|
|
|
from_container(T & t, concepts::SizedRange*, concepts::Sentinel*) |
47
|
|
|
|
|
|
|
{ |
48
|
|
|
|
|
|
|
return {begin(t), end(t), size(t)}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
template |
52
|
|
|
|
|
|
|
static iterator_range, sentinel_t> |
53
|
319
|
|
|
|
|
|
from_container(T & t, concepts::SizedRange*, concepts::SizedSentinel*) |
54
|
|
|
|
|
|
|
{ |
55
|
319
|
50
|
|
|
|
|
RANGES_ASSERT(size(t) == size(begin(t), end(t))); |
56
|
319
|
|
|
|
|
|
return {begin(t), end(t)}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
/// If it's a view already, pass it though. |
60
|
|
|
|
|
|
|
template
|
61
|
|
|
|
|
|
|
CONCEPT_REQUIRES_(View>())> |
62
|
957
|
|
|
|
|
|
static T from_range(T && t) |
63
|
|
|
|
|
|
|
{ |
64
|
957
|
|
|
|
|
|
return static_cast(t); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
/// If it is container-like, turn it into a view, being careful |
68
|
|
|
|
|
|
|
/// to preserve the Sized-ness of the range. |
69
|
|
|
|
|
|
|
template
|
70
|
|
|
|
|
|
|
CONCEPT_REQUIRES_(!View>()), |
71
|
|
|
|
|
|
|
typename I = iterator_t, |
72
|
|
|
|
|
|
|
typename S = sentinel_t, |
73
|
|
|
|
|
|
|
typename SIC = sized_range_concept, |
74
|
|
|
|
|
|
|
typename SIRC = sized_sentinel_concept> |
75
|
319
|
|
|
|
|
|
static auto from_range(T && t) -> |
76
|
|
|
|
|
|
|
decltype(all_fn::from_container(t, SIC(), SIRC())) |
77
|
|
|
|
|
|
|
{ |
78
|
|
|
|
|
|
|
static_assert(std::is_lvalue_reference::value, |
79
|
|
|
|
|
|
|
"Cannot get a view of a temporary container"); |
80
|
319
|
|
|
|
|
|
return all_fn::from_container(t, SIC(), SIRC()); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
// TODO handle char const * by turning it into a delimited range? |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
public: |
86
|
|
|
|
|
|
|
template
|
87
|
|
|
|
|
|
|
CONCEPT_REQUIRES_(Range())> |
88
|
1276
|
|
|
|
|
|
auto operator()(T && t) const -> |
89
|
|
|
|
|
|
|
decltype(all_fn::from_range(static_cast(t))) |
90
|
|
|
|
|
|
|
{ |
91
|
1276
|
|
|
|
|
|
return all_fn::from_range(static_cast(t)); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
template
|
95
|
|
|
|
|
|
|
CONCEPT_REQUIRES_(Range())> |
96
|
|
|
|
|
|
|
ranges::reference_wrapper operator()(std::reference_wrapper ref) const |
97
|
|
|
|
|
|
|
{ |
98
|
|
|
|
|
|
|
return ranges::ref(ref.get()); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
/// \relates all_fn |
103
|
|
|
|
|
|
|
/// \ingroup group-views |
104
|
|
|
|
|
|
|
RANGES_INLINE_VARIABLE(all_fn, all) |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
template |
107
|
|
|
|
|
|
|
using all_t = |
108
|
|
|
|
|
|
|
meta::_t()))>>; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
template |
112
|
|
|
|
|
|
|
struct identity_adaptor |
113
|
|
|
|
|
|
|
: Rng |
114
|
|
|
|
|
|
|
{ |
115
|
|
|
|
|
|
|
CONCEPT_ASSERT(View()); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
identity_adaptor() = default; |
118
|
|
|
|
|
|
|
constexpr explicit identity_adaptor(Rng const &rng) |
119
|
|
|
|
|
|
|
: Rng(rng) |
120
|
|
|
|
|
|
|
{} |
121
|
|
|
|
|
|
|
constexpr explicit identity_adaptor(Rng &&rng) |
122
|
|
|
|
|
|
|
: Rng(detail::move(rng)) |
123
|
|
|
|
|
|
|
{} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
using Rng::Rng; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR Rng &base() noexcept |
128
|
|
|
|
|
|
|
{ |
129
|
|
|
|
|
|
|
return *this; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
constexpr Rng const &base() const noexcept |
132
|
|
|
|
|
|
|
{ |
133
|
|
|
|
|
|
|
return *this; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
}; |
136
|
|
|
|
|
|
|
/// @} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
#endif |