Skip to content

Commit e004756

Browse files
committed
Use more idiomatic syntax for operator call
1 parent d1012a2 commit e004756

9 files changed

Lines changed: 35 additions & 39 deletions

File tree

‎rules/array/src.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ std::array<T1, T2> f4(std::array<T1, T2> &&o) {
2929

3030
template <typename T1, std::size_t T2>
3131
std::array<T1, T2> &f5(std::array<T1, T2> &dst, std::array<T1, T2> &&src) {
32-
return dst.operator=(std::move(src));
32+
return dst = std::move(src);
3333
}
3434

3535
template <typename T1, std::size_t T2>
@@ -39,5 +39,5 @@ std::array<T1, T2> f6(const std::array<T1, T2> &o) {
3939

4040
template <typename T1, std::size_t T2>
4141
std::array<T1, T2> &f7(std::array<T1, T2> &dst, const std::array<T1, T2> &src) {
42-
return dst.operator=(src);
42+
return dst = src;
4343
}

‎rules/compare/src_cxx20.cpp‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,24 @@ std::strong_ordering f3() { return std::strong_ordering::equivalent; }
1313

1414
std::strong_ordering f4() { return std::strong_ordering::greater; }
1515

16-
bool f5(std::strong_ordering a0, std::strong_ordering a1) {
17-
return operator==(a0, a1);
18-
}
16+
bool f5(std::strong_ordering a0, std::strong_ordering a1) { return a0 == a1; }
1917

2018
template <typename T1> bool f6(std::strong_ordering a0, T1 a1) {
21-
return operator==(a0, 0);
19+
return a0 == 0;
2220
}
2321

2422
template <typename T1> bool f7(std::strong_ordering a0, T1 a1) {
25-
return operator<(a0, 0);
23+
return a0 < 0;
2624
}
2725

2826
template <typename T1> bool f8(std::strong_ordering a0, T1 a1) {
29-
return operator>(a0, 0);
27+
return a0 > 0;
3028
}
3129

3230
template <typename T1> bool f9(std::strong_ordering a0, T1 a1) {
33-
return operator<=(a0, 0);
31+
return a0 <= 0;
3432
}
3533

3634
template <typename T1> bool f10(std::strong_ordering a0, T1 a1) {
37-
return operator>=(a0, 0);
35+
return a0 >= 0;
3836
}

‎rules/cstddef/src_cxx17.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
using t1 = std::byte;
77

8-
std::byte f1(const std::byte &a0, unsigned a1) { return operator<<(a0, a1); }
8+
std::byte f1(const std::byte &a0, unsigned a1) { return a0 << a1; }
99

10-
std::byte f2(const std::byte &a0, unsigned a1) { return operator>>(a0, a1); }
10+
std::byte f2(const std::byte &a0, unsigned a1) { return a0 >> a1; }
1111

12-
std::byte f3(std::byte &a0, unsigned a1) { return operator<<=(a0, a1); }
12+
std::byte f3(std::byte &a0, unsigned a1) { return a0 <<= a1; }
1313

14-
std::byte f4(std::byte &a0, unsigned a1) { return operator>>=(a0, a1); }
14+
std::byte f4(std::byte &a0, unsigned a1) { return a0 >>= a1; }

‎rules/deque/src.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ template <typename T1> std::deque<T1> f9(std::deque<T1> &&o) {
3737

3838
template <typename T1>
3939
std::deque<T1> &f10(std::deque<T1> &dst, const std::deque<T1> &src) {
40-
return dst.operator=(src);
40+
return dst = src;
4141
}
4242

4343
template <typename T1>
4444
std::deque<T1> &f11(std::deque<T1> &dst, std::deque<T1> &&src) {
45-
return dst.operator=(std::move(src));
45+
return dst = std::move(src);
4646
}
4747

4848
template <typename T1, typename... Args>

‎rules/map/src.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ template <typename T1, typename T2>
2222
using t4 = typename std::map<T1, T2>::size_type;
2323

2424
template <typename T1, typename T2> T2 &f1(std::map<T1, T2> &o, const T1 &key) {
25-
return o.operator[](key);
25+
return o[key];
2626
}
2727

2828
template <typename T1, typename T2> std::size_t f2(const std::map<T1, T2> &o) {
@@ -49,7 +49,7 @@ template <typename T1, typename T2> T2 &f7(std::map<T1, T2> &o, const T1 &key) {
4949
}
5050

5151
template <typename T1, typename T2> T2 &f8(std::map<T1, T2> &o, T1 &&key) {
52-
return o.operator[](std::move(key));
52+
return o[std::move(key)];
5353
}
5454

5555
template <typename T1, typename T2>
@@ -76,7 +76,7 @@ typename std::map<T1, T2>::iterator f12(std::map<T1, T2> &o) {
7676
template <typename It, typename T1 = KeyOf<It>, typename T2 = MappedOf<It>,
7777
typename = SameAs<It, typename std::map<T1, T2>::const_iterator>>
7878
bool f13(It a, It b) {
79-
return operator==(a, b);
79+
return a == b;
8080
}
8181

8282
template <typename T1, typename T2>
@@ -92,7 +92,7 @@ const T2 &f15(const std::map<T1, T2> &o, const T1 &key) {
9292
template <typename It, typename T1 = KeyOf<It>, typename T2 = MappedOf<It>,
9393
typename = SameAs<It, typename std::map<T1, T2>::iterator>>
9494
bool f16(It a, It b) {
95-
return operator==(a, b);
95+
return a == b;
9696
}
9797

9898
template <typename T1, typename T2>
@@ -137,12 +137,12 @@ template <typename T1, typename T2> std::map<T1, T2> f24(std::map<T1, T2> &&o) {
137137

138138
template <typename T1, typename T2>
139139
std::map<T1, T2> &f25(std::map<T1, T2> &dst, std::map<T1, T2> &&src) {
140-
return dst.operator=(std::move(src));
140+
return dst = std::move(src);
141141
}
142142

143143
template <typename T1, typename T2>
144144
std::map<T1, T2> &f26(std::map<T1, T2> &dst, const std::map<T1, T2> &src) {
145-
return dst.operator=(src);
145+
return dst = src;
146146
}
147147

148148
template <typename It, typename T1 = KeyOf<It>, typename T2 = MappedOf<It>,

‎rules/pair/src.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ std::pair<T1, T2> f12(std::pair<T1, T2> &&a0) {
3333

3434
template <typename T1, typename T2>
3535
std::pair<T1, T2> &f13(std::pair<T1, T2> &dst, const std::pair<T1, T2> &src) {
36-
return dst.operator=(src);
36+
return dst = src;
3737
}
3838

3939
template <typename T1, typename T2>
4040
std::pair<T1, T2> &f14(std::pair<T1, T2> &dst, std::pair<T1, T2> &&src) {
41-
return dst.operator=(std::move(src));
41+
return dst = std::move(src);
4242
}
4343

4444
template <typename T1, typename T2> const T2 &f15(const std::pair<T1, T2> &a0) {

‎rules/string/src.cpp‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ std::string f27(const std::string &o) { return std::string(o); }
7979

8080
std::string f28(std::string &&o) { return std::string(std::move(o)); }
8181

82-
std::string &f29(std::string &dst, const std::string &src) {
83-
return dst.operator=(src);
84-
}
82+
std::string &f29(std::string &dst, const std::string &src) { return dst = src; }
8583

8684
std::string &f30(std::string &dst, std::string &&src) {
87-
return dst.operator=(std::move(src));
85+
return dst = std::move(src);
8886
}

‎rules/unique_ptr/src.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ template <typename T1> std::unique_ptr<T1[]> f13(std::unique_ptr<T1[]> &&o) {
5555

5656
template <typename T1>
5757
std::unique_ptr<T1> &f14(std::unique_ptr<T1> &dst, std::unique_ptr<T1> &&src) {
58-
return dst.operator=(std::move(src));
58+
return dst = std::move(src);
5959
}
6060

6161
template <typename T1>
6262
std::unique_ptr<T1[]> &f15(std::unique_ptr<T1[]> &dst,
6363
std::unique_ptr<T1[]> &&src) {
64-
return dst.operator=(std::move(src));
64+
return dst = std::move(src);
6565
}

‎rules/vector/src.cpp‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ template <typename It, typename T1 = ValueOf<It>,
176176
typename T2 = AllocatorOf<It, std::allocator<T1>>,
177177
typename = SameAs<It, typename std::vector<T1, T2>::iterator>>
178178
typename std::vector<T1, T2>::reference f81(It it) {
179-
return it.operator*();
179+
return *it;
180180
}
181181

182182
template <typename It, typename T1 = ValueOf<It>,
@@ -197,7 +197,7 @@ template <typename It, typename T1 = ValueOf<It>,
197197
typename T2 = AllocatorOf<It, std::allocator<T1>>,
198198
typename = SameAs<It, typename std::vector<T1, T2>::iterator>>
199199
typename std::vector<T1, T2>::iterator f84(It it, std::size_t n) {
200-
return it.operator+(n);
200+
return it + n;
201201
}
202202

203203
template <typename It, typename T1 = ValueOf<It>,
@@ -211,29 +211,29 @@ template <typename It, typename T1 = ValueOf<It>,
211211
typename T2 = AllocatorOf<It, std::allocator<T1>>,
212212
typename = SameAs<It, typename std::vector<T1, T2>::iterator>>
213213
bool f86(const It &it1, const It &it2) {
214-
return operator==(it1, it2);
214+
return it1 == it2;
215215
}
216216

217217
template <typename It, typename T1 = ValueOf<It>,
218218
typename T2 = AllocatorOf<It, std::allocator<T1>>,
219219
typename = SameAs<It, typename std::vector<T1, T2>::iterator>>
220220
typename std::vector<T1, T2>::iterator f87(It a0, int a1) {
221-
return a0.operator++(a1);
221+
return a0++;
222222
}
223223

224224
template <typename It, typename T1 = ValueOf<It>,
225225
typename T2 = AllocatorOf<It, std::allocator<T1>>,
226226
typename = SameAs<It, typename std::vector<T1, T2>::iterator>>
227227
typename std::vector<T1, T2>::iterator::difference_type f88(const It &it1,
228228
const It &it2) {
229-
return operator-(it1, it2);
229+
return it1 - it2;
230230
}
231231

232232
template <typename It, typename T1 = ValueOf<It>,
233233
typename T2 = AllocatorOf<It, std::allocator<T1>>,
234234
typename = SameAs<It, typename std::vector<T1, T2>::iterator>>
235235
typename std::vector<T1, T2>::iterator &f89(It &it) {
236-
return it.operator++();
236+
return ++it;
237237
}
238238

239239
template <typename T1, typename T2 = std::allocator<T1>>
@@ -309,7 +309,7 @@ void f102(std::vector<T1, T2> &o, std::size_t n,
309309

310310
template <typename T1, typename T2 = std::allocator<T1>>
311311
std::vector<T1, T2> &f103(std::vector<T1, T2> &dst, std::vector<T1, T2> &&src) {
312-
return dst.operator=(std::move(src));
312+
return dst = std::move(src);
313313
}
314314

315315
template <typename T1, typename T2 = std::allocator<T1>>
@@ -321,7 +321,7 @@ f104(const std::vector<T1, T2> &o) {
321321
template <typename T1, typename T2 = std::allocator<T1>>
322322
std::vector<T1, T2> &f105(std::vector<T1, T2> &dst,
323323
const std::vector<T1, T2> &src) {
324-
return dst.operator=(src);
324+
return dst = src;
325325
}
326326

327327
template <typename T1, typename T2 = std::allocator<T1>>
@@ -342,7 +342,7 @@ std::vector<T1, T2> f110(const std::vector<T1, T2> &o) {
342342
template <typename T1>
343343
std::vector<std::vector<T1>> &f111(std::vector<std::vector<T1>> &dst,
344344
std::vector<std::vector<T1>> &&src) {
345-
return dst.operator=(std::move(src));
345+
return dst = std::move(src);
346346
}
347347

348348
template <typename T1, typename... Args>

0 commit comments

Comments
 (0)