@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2323
2424#include < algorithm>
2525#include < array>
26+ #include < ranges>
2627
2728#include < utki/enum_array.hpp>
2829#include < utki/sort.hpp>
@@ -172,6 +173,8 @@ struct key_name_key_pair {
172173
173174 // This constructor is added to suppress clang-tidy to ask using designated initializers,
174175 // when constructing key_name_key_pair items in the array, because it looks clearer without them.
176+ // Since the structure is called a pair and the two values are of different types it is obvious
177+ // to construct it by just specifying the two values without specifying which is what.
175178 constexpr key_name_key_pair (std::string_view name, ruis::key key) :
176179 name(name),
177180 key(key)
@@ -292,13 +295,11 @@ constexpr auto key_name_to_key_ordered_mapping = []() constexpr {
292295
293296ruis::key ruis::to_key (std::string_view name)
294297{
295- auto i = std::lower_bound (
296- key_name_to_key_ordered_mapping.begin (),
297- key_name_to_key_ordered_mapping.end (),
298+ auto i = std::ranges::lower_bound (
299+ key_name_to_key_ordered_mapping, //
298300 name,
299- [](const auto & a, const std::string_view& b) {
300- return a.name < b;
301- }
301+ {}, // comparison function, empty means to use operator<()
302+ &key_name_key_pair::name
302303 );
303304 if (i != key_name_to_key_ordered_mapping.end () && i->name == name) {
304305 return i->key ;
0 commit comments