line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/// \file |
2
|
|
|
|
|
|
|
// Range v3 library |
3
|
|
|
|
|
|
|
// |
4
|
|
|
|
|
|
|
// Copyright Eric Niebler 2013-present |
5
|
|
|
|
|
|
|
// Copyright Casey Carter 2016 |
6
|
|
|
|
|
|
|
// |
7
|
|
|
|
|
|
|
// Use, modification and distribution is subject to the |
8
|
|
|
|
|
|
|
// Boost Software License, Version 1.0. (See accompanying |
9
|
|
|
|
|
|
|
// file LICENSE_1_0.txt or copy at |
10
|
|
|
|
|
|
|
// http://www.boost.org/LICENSE_1_0.txt) |
11
|
|
|
|
|
|
|
// |
12
|
|
|
|
|
|
|
// Project home: https://github.com/ericniebler/range-v3 |
13
|
|
|
|
|
|
|
// |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#ifndef RANGES_V3_UTILITY_COMPRESSED_PAIR_HPP |
16
|
|
|
|
|
|
|
#define RANGES_V3_UTILITY_COMPRESSED_PAIR_HPP |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#include |
19
|
|
|
|
|
|
|
#include |
20
|
|
|
|
|
|
|
#include |
21
|
|
|
|
|
|
|
#include |
22
|
|
|
|
|
|
|
#include |
23
|
|
|
|
|
|
|
#include |
24
|
|
|
|
|
|
|
#include |
25
|
|
|
|
|
|
|
#include |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
namespace ranges |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
inline namespace v3 |
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
/// \cond |
32
|
|
|
|
|
|
|
namespace compressed_tuple_detail |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
// tagging individual elements with the complete type list disambiguates |
35
|
|
|
|
|
|
|
// base classes when composing compressed_tuples recursively. |
36
|
|
|
|
|
|
|
template |
37
|
|
|
|
|
|
|
using storage = box, Ts...>>; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
template struct compressed_tuple_; |
40
|
|
|
|
|
|
|
template |
41
|
|
|
|
|
|
|
struct RANGES_EMPTY_BASES compressed_tuple_, meta::index_sequence> |
42
|
|
|
|
|
|
|
: storage... |
43
|
|
|
|
|
|
|
{ |
44
|
|
|
|
|
|
|
static_assert(Same, |
45
|
|
|
|
|
|
|
meta::make_index_sequence>(), "What madness is this?!?"); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
compressed_tuple_() = default; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
template
|
50
|
|
|
|
|
|
|
meta::if_...>, int> = 0> |
51
|
1595
|
|
|
|
|
|
constexpr compressed_tuple_(Args &&... args) |
52
|
|
|
|
|
|
|
noexcept(meta::strict_and, Args>...>::value) |
53
|
1595
|
|
|
|
|
|
: storage{static_cast(args)}... |
54
|
1595
|
|
|
|
|
|
{} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
template
|
57
|
|
|
|
|
|
|
meta::if_...>, int> = 0> |
58
|
|
|
|
|
|
|
constexpr operator std::tuple () const |
59
|
|
|
|
|
|
|
noexcept(meta::strict_and...>::value) |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
return std::tuple{get(*this)...}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
template |
66
|
|
|
|
|
|
|
using compressed_tuple = |
67
|
|
|
|
|
|
|
compressed_tuple_, meta::make_index_sequence>; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
template, I>> |
70
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR T & |
71
|
1881
|
|
|
|
|
|
get(compressed_tuple_, meta::index_sequence> &tuple) noexcept |
72
|
|
|
|
|
|
|
{ |
73
|
1881
|
|
|
|
|
|
return static_cast &>(tuple).get(); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
template, I>> |
76
|
|
|
|
|
|
|
constexpr T const & |
77
|
3454
|
|
|
|
|
|
get(compressed_tuple_, meta::index_sequence> const &tuple) noexcept |
78
|
|
|
|
|
|
|
{ |
79
|
3454
|
|
|
|
|
|
return static_cast const &>(tuple).get(); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
template, I>> |
82
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR T && |
83
|
|
|
|
|
|
|
get(compressed_tuple_, meta::index_sequence> &&tuple) noexcept |
84
|
|
|
|
|
|
|
{ |
85
|
|
|
|
|
|
|
return static_cast &&>(tuple).get(); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
template, I>> |
88
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR T const && |
89
|
|
|
|
|
|
|
get(compressed_tuple_, meta::index_sequence> const &&tuple) noexcept |
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
return static_cast const &&>(tuple).get(); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
/// \endcond |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
using compressed_tuple_detail::compressed_tuple; |
97
|
|
|
|
|
|
|
using compressed_tuple_detail::get; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
struct make_compressed_tuple_fn |
100
|
|
|
|
|
|
|
{ |
101
|
|
|
|
|
|
|
template |
102
|
|
|
|
|
|
|
constexpr auto operator()(Args &&... args) const |
103
|
|
|
|
|
|
|
RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT( |
104
|
|
|
|
|
|
|
compressed_tuple...>{static_cast(args)...} |
105
|
|
|
|
|
|
|
) |
106
|
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
/// \ingroup group-utility |
109
|
|
|
|
|
|
|
/// \sa `make_compressed_tuple_fn` |
110
|
|
|
|
|
|
|
RANGES_INLINE_VARIABLE(make_compressed_tuple_fn, make_compressed_tuple) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
template |
113
|
|
|
|
|
|
|
using tagged_compressed_tuple = |
114
|
|
|
|
|
|
|
tagged...>, detail::tag_spec...>; |
115
|
|
|
|
|
|
|
|
116
|
7568
|
|
|
|
|
|
RANGES_DEFINE_TAG_SPECIFIER(first) |
117
|
5676
|
|
|
|
|
|
RANGES_DEFINE_TAG_SPECIFIER(second) |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
template |
120
|
|
|
|
|
|
|
struct compressed_pair |
121
|
|
|
|
|
|
|
: tagged_compressed_tuple |
122
|
|
|
|
|
|
|
{ |
123
|
|
|
|
|
|
|
using base_t = tagged_compressed_tuple; |
124
|
|
|
|
|
|
|
using first_type = First; |
125
|
|
|
|
|
|
|
using second_type = Second; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
using base_t::first; |
128
|
|
|
|
|
|
|
using base_t::second; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
compressed_pair() = default; |
131
|
2552
|
|
|
|
|
|
using base_t::base_t; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
template
|
134
|
|
|
|
|
|
|
meta::if_, |
135
|
|
|
|
|
|
|
std::is_constructible>, int> = 0> |
136
|
|
|
|
|
|
|
constexpr operator std::pair () const |
137
|
|
|
|
|
|
|
noexcept(std::is_nothrow_constructible::value && |
138
|
|
|
|
|
|
|
std::is_nothrow_constructible::value) |
139
|
|
|
|
|
|
|
{ |
140
|
|
|
|
|
|
|
return std::pair{first(), second()}; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
}; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
struct make_compressed_pair_fn |
145
|
|
|
|
|
|
|
{ |
146
|
|
|
|
|
|
|
template |
147
|
|
|
|
|
|
|
constexpr auto operator()(First && f, Second && s) const |
148
|
|
|
|
|
|
|
RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT( |
149
|
|
|
|
|
|
|
compressed_pair, bind_element_t>{ |
150
|
|
|
|
|
|
|
static_cast(f), static_cast(s) |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
) |
153
|
|
|
|
|
|
|
}; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
/// \ingroup group-utility |
156
|
|
|
|
|
|
|
/// \sa `make_compressed_pair_fn` |
157
|
|
|
|
|
|
|
RANGES_INLINE_VARIABLE(make_compressed_pair_fn, make_compressed_pair) |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
RANGES_DIAGNOSTIC_PUSH |
162
|
|
|
|
|
|
|
RANGES_DIAGNOSTIC_IGNORE_MISMATCHED_TAGS |
163
|
|
|
|
|
|
|
namespace std |
164
|
|
|
|
|
|
|
{ |
165
|
|
|
|
|
|
|
template |
166
|
|
|
|
|
|
|
struct tuple_size< ::ranges::v3::compressed_tuple_detail::compressed_tuple_<::meta::list, ::meta::index_sequence>> |
167
|
|
|
|
|
|
|
: integral_constant |
168
|
|
|
|
|
|
|
{}; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
template |
171
|
|
|
|
|
|
|
struct tuple_element, ::meta::index_sequence>> |
172
|
|
|
|
|
|
|
{ |
173
|
|
|
|
|
|
|
using type = ::meta::at_c<::meta::list, I>; |
174
|
|
|
|
|
|
|
}; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
template |
177
|
|
|
|
|
|
|
struct tuple_size< ::ranges::v3::compressed_pair> |
178
|
|
|
|
|
|
|
: integral_constant |
179
|
|
|
|
|
|
|
{}; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
template |
182
|
|
|
|
|
|
|
struct tuple_element<0, ::ranges::v3::compressed_pair> |
183
|
|
|
|
|
|
|
{ |
184
|
|
|
|
|
|
|
using type = First; |
185
|
|
|
|
|
|
|
}; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
template |
188
|
|
|
|
|
|
|
struct tuple_element<1, ::ranges::v3::compressed_pair> |
189
|
|
|
|
|
|
|
{ |
190
|
|
|
|
|
|
|
using type = Second; |
191
|
|
|
|
|
|
|
}; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
RANGES_DIAGNOSTIC_POP |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
#endif |