@@ -23,20 +23,20 @@ struct [[nodiscard]] sorted_map_key
2323 {
2424 }
2525
26- constexpr sorted_map_key (const K& key) noexcept
26+ constexpr sorted_map_key (K key) noexcept
2727 : key { key }
2828 {
2929 }
3030
3131 constexpr ~sorted_map_key () noexcept = default ;
3232
33- const K& key;
33+ K key;
3434};
3535
3636template <class Compare , class Iterator , class K ,
3737 class V = decltype (std::declval<Iterator>()->second)>
3838[[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
4040{
4141 return std::equal_range (itrBegin,
4242 itrEnd,
@@ -47,7 +47,7 @@ template <class Compare, class Iterator, class K,
4747}
4848
4949template <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
5151{
5252 const auto [itr, itrEnd] =
5353 sorted_map_equal_range<Compare>(container.begin (), container.end (), key);
@@ -131,7 +131,7 @@ class [[nodiscard]] sorted_map
131131 return _data.rend ();
132132 }
133133
134- [[nodiscard]] constexpr const_iterator find (const K& key) const noexcept
134+ [[nodiscard]] constexpr const_iterator find (K key) const noexcept
135135 {
136136 const auto [itr, itrEnd] = sorted_map_equal_range<Compare>(_data.begin (), _data.end (), key);
137137
@@ -161,7 +161,7 @@ class [[nodiscard]] sorted_map
161161 true };
162162 }
163163
164- inline const_iterator erase (const K& key) noexcept
164+ inline const_iterator erase (K key) noexcept
165165 {
166166 const auto [itr, itrEnd] = sorted_map_equal_range<Compare>(_data.begin (), _data.end (), key);
167167
@@ -291,12 +291,11 @@ class [[nodiscard]] sorted_set
291291 return _data.rend ();
292292 }
293293
294- [[nodiscard]] constexpr const_iterator find (const K& key) const noexcept
294+ [[nodiscard]] constexpr const_iterator find (K key) const noexcept
295295 {
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+ });
300299
301300 return itr == itrEnd ? _data.end () : itr;
302301 }
@@ -312,10 +311,8 @@ class [[nodiscard]] sorted_set
312311 template <typename Arg>
313312 inline std::pair<const_iterator, bool > emplace (Arg&& key) noexcept
314313 {
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 {
319316 return Compare {}(lhs, rhs);
320317 });
321318
@@ -327,12 +324,10 @@ class [[nodiscard]] sorted_set
327324 return { _data.emplace (itrEnd, std::forward<Arg>(key)), true };
328325 }
329326
330- inline const_iterator erase (const K& key) noexcept
327+ inline const_iterator erase (K key) noexcept
331328 {
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 {
336331 return Compare {}(lhs, rhs);
337332 });
338333
@@ -364,7 +359,7 @@ class [[nodiscard]] sorted_set
364359struct [[nodiscard]] shorter_or_less
365360{
366361 [[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
368363 {
369364 return lhs.size () == rhs.size () ? lhs < rhs : lhs.size () < rhs.size ();
370365 }
0 commit comments