@@ -23,20 +23,20 @@ struct [[nodiscard]] sorted_map_key
23
23
{
24
24
}
25
25
26
- constexpr sorted_map_key (const K& key) noexcept
26
+ constexpr sorted_map_key (K key) noexcept
27
27
: key { key }
28
28
{
29
29
}
30
30
31
31
constexpr ~sorted_map_key () noexcept = default ;
32
32
33
- const K& key;
33
+ K key;
34
34
};
35
35
36
36
template <class Compare , class Iterator , class K ,
37
37
class V = decltype (std::declval<Iterator>()->second)>
38
38
[[nodiscard]] constexpr std::pair<Iterator, Iterator> sorted_map_equal_range (
39
- Iterator itrBegin, Iterator itrEnd, const K& key) noexcept
39
+ Iterator itrBegin, Iterator itrEnd, K key) noexcept
40
40
{
41
41
return std::equal_range (itrBegin,
42
42
itrEnd,
@@ -47,7 +47,7 @@ template <class Compare, class Iterator, class K,
47
47
}
48
48
49
49
template <class Compare , class Container , class K >
50
- [[nodiscard]] constexpr auto sorted_map_lookup (const Container& container, const K& key) noexcept
50
+ [[nodiscard]] constexpr auto sorted_map_lookup (const Container& container, K key) noexcept
51
51
{
52
52
const auto [itr, itrEnd] =
53
53
sorted_map_equal_range<Compare>(container.begin (), container.end (), key);
@@ -131,7 +131,7 @@ class [[nodiscard]] sorted_map
131
131
return _data.rend ();
132
132
}
133
133
134
- [[nodiscard]] constexpr const_iterator find (const K& key) const noexcept
134
+ [[nodiscard]] constexpr const_iterator find (K key) const noexcept
135
135
{
136
136
const auto [itr, itrEnd] = sorted_map_equal_range<Compare>(_data.begin (), _data.end (), key);
137
137
@@ -161,7 +161,7 @@ class [[nodiscard]] sorted_map
161
161
true };
162
162
}
163
163
164
- inline const_iterator erase (const K& key) noexcept
164
+ inline const_iterator erase (K key) noexcept
165
165
{
166
166
const auto [itr, itrEnd] = sorted_map_equal_range<Compare>(_data.begin (), _data.end (), key);
167
167
@@ -291,12 +291,11 @@ class [[nodiscard]] sorted_set
291
291
return _data.rend ();
292
292
}
293
293
294
- [[nodiscard]] constexpr const_iterator find (const K& key) const noexcept
294
+ [[nodiscard]] constexpr const_iterator find (K key) const noexcept
295
295
{
296
- const auto [itr, itrEnd] =
297
- std::equal_range (begin (), end (), key, [](const K& lhs, const K& rhs) noexcept {
298
- return Compare {}(lhs, rhs);
299
- });
296
+ const auto [itr, itrEnd] = std::equal_range (begin (), end (), key, [](K lhs, K rhs) noexcept {
297
+ return Compare {}(lhs, rhs);
298
+ });
300
299
301
300
return itr == itrEnd ? _data.end () : itr;
302
301
}
@@ -312,10 +311,8 @@ class [[nodiscard]] sorted_set
312
311
template <typename Arg>
313
312
inline std::pair<const_iterator, bool > emplace (Arg&& key) noexcept
314
313
{
315
- const auto [itr, itrEnd] = std::equal_range (_data.begin (),
316
- _data.end (),
317
- key,
318
- [](const auto & lhs, const auto & rhs) noexcept {
314
+ const auto [itr, itrEnd] =
315
+ std::equal_range (_data.begin (), _data.end (), key, [](K lhs, K rhs) noexcept {
319
316
return Compare {}(lhs, rhs);
320
317
});
321
318
@@ -327,12 +324,10 @@ class [[nodiscard]] sorted_set
327
324
return { _data.emplace (itrEnd, std::forward<Arg>(key)), true };
328
325
}
329
326
330
- inline const_iterator erase (const K& key) noexcept
327
+ inline const_iterator erase (K key) noexcept
331
328
{
332
- const auto [itr, itrEnd] = std::equal_range (_data.begin (),
333
- _data.end (),
334
- key,
335
- [](const K& lhs, const K& rhs) noexcept {
329
+ const auto [itr, itrEnd] =
330
+ std::equal_range (_data.begin (), _data.end (), key, [](K lhs, K rhs) noexcept {
336
331
return Compare {}(lhs, rhs);
337
332
});
338
333
@@ -364,7 +359,7 @@ class [[nodiscard]] sorted_set
364
359
struct [[nodiscard]] shorter_or_less
365
360
{
366
361
[[nodiscard]] constexpr bool operator ()(
367
- const std::string_view& lhs, const std::string_view& rhs) const noexcept
362
+ std::string_view lhs, std::string_view rhs) const noexcept
368
363
{
369
364
return lhs.size () == rhs.size () ? lhs < rhs : lhs.size () < rhs.size ();
370
365
}
0 commit comments