Skip to content

Commit 5a3996a

Browse files
committed
Various cleanups
1 parent e55c077 commit 5a3996a

File tree

9 files changed

+183
-254
lines changed

9 files changed

+183
-254
lines changed

libcxx/include/__ranges/join_with_view.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ struct join_with_view<_View, _Pattern>::__iterator
247247
if constexpr (__ref_is_glvalue)
248248
return std::__as_lvalue(*__get_outer());
249249
else
250-
return __parent_->__inner_.__emplace_from([&]() -> decltype(auto) { return *__get_outer(); });
250+
return __parent_->__inner_.__emplace_from([this]() -> decltype(auto) { return *__get_outer(); });
251251
}
252252

253253
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __get_inner() {

libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/no_unique_address.compile.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ using JWV = std::ranges::join_with_view<View, IntRange>;
5252
// Expected JWV::iterator layout:
5353
// _Parent* __parent_; // offset: 0
5454
// [[no_unique_address]] __empty __outer_it; // 0
55-
// variant<_PatternIter, _InnerIter> __pattern_; // 8
55+
// variant<_PatternIter, _InnerIter> __pattern_; // sizeof(pointer)
5656
static_assert(sizeof(std::ranges::iterator_t<JWV>) ==
5757
sizeof(void*) + sizeof(std::variant<int*, int*>)); // sizeof(__parent_) + sizeof(__inner_it_)

libcxx/test/std/ranges/range.adaptors/range.join.with/range.join.with.iterator/deref.pass.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525

2626
#include "../types.h"
2727

28-
struct ProxyInt {
28+
struct ProxyRef {
2929
int& val;
3030
};
3131

32-
class ExtraProxyInt {
32+
class CommonProxyRef {
3333
public:
34-
constexpr ExtraProxyInt(ProxyInt i) : val(i.val) {}
35-
constexpr ExtraProxyInt(int i) : val(i) {}
34+
constexpr CommonProxyRef(ProxyRef i) : val(i.val) {}
35+
constexpr CommonProxyRef(int i) : val(i) {}
3636

3737
constexpr int get() const { return val; }
3838

@@ -41,17 +41,17 @@ class ExtraProxyInt {
4141
};
4242

4343
template <template <class> class TQual, template <class> class UQual>
44-
struct std::basic_common_reference<ProxyInt, int, TQual, UQual> {
45-
using type = ExtraProxyInt;
44+
struct std::basic_common_reference<ProxyRef, int, TQual, UQual> {
45+
using type = CommonProxyRef;
4646
};
4747

4848
template <template <class> class TQual, template <class> class UQual>
49-
struct std::basic_common_reference<int, ProxyInt, TQual, UQual> {
50-
using type = ExtraProxyInt;
49+
struct std::basic_common_reference<int, ProxyRef, TQual, UQual> {
50+
using type = CommonProxyRef;
5151
};
5252

53-
static_assert(std::common_reference_with<int&, ProxyInt>);
54-
static_assert(std::common_reference_with<int&, ExtraProxyInt>);
53+
static_assert(std::common_reference_with<int&, ProxyRef>);
54+
static_assert(std::common_reference_with<int&, CommonProxyRef>);
5555

5656
class ProxyIter {
5757
public:
@@ -61,7 +61,7 @@ class ProxyIter {
6161
constexpr ProxyIter() : ptr_(nullptr) {}
6262
constexpr explicit ProxyIter(int* p) : ptr_(p) {}
6363

64-
constexpr ProxyInt operator*() const { return ProxyInt{*ptr_}; }
64+
constexpr ProxyRef operator*() const { return ProxyRef{*ptr_}; }
6565

6666
constexpr ProxyIter& operator++() {
6767
++ptr_;
@@ -196,21 +196,21 @@ constexpr bool test() {
196196
using Inner = std::vector<int>;
197197
using V = std::vector<Inner>;
198198
using Pattern = std::ranges::subrange<ProxyIter, ProxyIter>;
199-
using JWV = std::ranges::join_with_view<std::ranges::owning_view<V>, std::ranges::owning_view<Pattern>>;
199+
using JWV = std::ranges::join_with_view<std::ranges::owning_view<V>, Pattern>;
200200

201201
static_assert(!std::same_as<std::ranges::range_reference_t<V>, std::ranges::range_reference_t<JWV>>);
202202
static_assert(!std::same_as<std::ranges::range_reference_t<Pattern>, std::ranges::range_reference_t<JWV>>);
203203

204204
std::array<int, 2> pattern = {-1, -1};
205205
Pattern pattern_as_subrange(ProxyIter{pattern.data()}, ProxyIter{pattern.data() + pattern.size()});
206206

207-
JWV jwv(V{Inner{1, 1}, Inner{2, 2}, Inner{3, 3}}, std::move(pattern_as_subrange));
207+
JWV jwv(V{Inner{1, 1}, Inner{2, 2}, Inner{3, 3}}, pattern_as_subrange);
208208

209-
auto it = jwv.begin();
210-
std::same_as<ExtraProxyInt> decltype(auto) v_ref = *it;
209+
auto it = jwv.begin();
210+
std::same_as<CommonProxyRef> decltype(auto) v_ref = *it;
211211
assert(v_ref.get() == 1);
212212
std::ranges::advance(it, 7);
213-
std::same_as<ExtraProxyInt> decltype(auto) pattern_ref = *std::as_const(it);
213+
std::same_as<CommonProxyRef> decltype(auto) pattern_ref = *std::as_const(it);
214214
assert(pattern_ref.get() == -1);
215215
}
216216

0 commit comments

Comments
 (0)