diff --git a/src/command_manager.cc b/src/command_manager.cc index 2c067978..a8212d06 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -297,14 +297,15 @@ Token parse_percent_token(ParseState& state, bool throw_on_unterminated) } } -template> or std::is_same_v>> +template + requires (std::is_same_v> or std::is_same_v) void expand_token(Token&& token, const Context& context, const ShellContext& shell_context, Target& target) { constexpr bool single = std::is_same_v; auto set_target = [&](auto&& s) { if constexpr (single) target = std::move(s); - else if constexpr (std::is_same_v, String>) + else if constexpr (std::is_same_v, String>) target.push_back(std::move(s)); else if constexpr (std::is_same_v&&>) target.insert(target.end(), std::make_move_iterator(s.begin()), std::make_move_iterator(s.end())); diff --git a/src/keys.hh b/src/keys.hh index f06a7e2f..da2895e7 100644 --- a/src/keys.hh +++ b/src/keys.hh @@ -84,7 +84,7 @@ struct Key constexpr uint64_t val() const { return (uint64_t)modifiers << 32 | key; } constexpr bool operator==(Key other) const { return val() == other.val(); } - constexpr bool operator<(Key other) const { return val() < other.val(); } + constexpr std::strong_ordering operator<=>(Key other) const { return val() <=> other.val(); } constexpr DisplayCoord coord() const { return {(int)((key & 0xFFFF0000) >> 16), (int)(key & 0x0000FFFF)}; } constexpr MouseButton mouse_button() { return MouseButton{((int)modifiers & (int)Modifiers::MouseButtonMask) >> 6}; } diff --git a/src/ranges.hh b/src/ranges.hh index 5fb1e2c9..cf436880 100644 --- a/src/ranges.hh +++ b/src/ranges.hh @@ -15,8 +15,7 @@ namespace Kakoune template struct ViewFactory { Func func; }; template -ViewFactory> -make_view_factory(Func&& func) { return {std::forward(func)}; } +ViewFactory(Func&&) -> ViewFactory>; template decltype(auto) operator| (Range&& range, ViewFactory factory) @@ -50,10 +49,10 @@ struct ReverseView inline auto reverse() { - return make_view_factory([](auto&& range) { + return ViewFactory{[](auto&& range) { using Range = decltype(range); return ReverseView>{std::forward(range)}; - }); + }}; } template @@ -74,10 +73,10 @@ struct SkipView inline auto skip(size_t count) { - return make_view_factory([count](auto&& range) { + return ViewFactory{[count](auto&& range) { using Range = decltype(range); return SkipView>{std::forward(range), count}; - }); + }}; } template @@ -92,10 +91,10 @@ struct DropView inline auto drop(size_t count) { - return make_view_factory([count](auto&& range) { + return ViewFactory{[count](auto&& range) { using Range = decltype(range); return DropView>{std::forward(range), count}; - }); + }}; } template @@ -150,10 +149,10 @@ struct FilterView template inline auto filter(Filter f) { - return make_view_factory([f = std::move(f)](auto&& range) { + return ViewFactory{[f = std::move(f)](auto&& range) { using Range = decltype(range); return FilterView, Filter>{std::forward(range), std::move(f)}; - }); + }}; } template @@ -196,10 +195,10 @@ struct EnumerateView inline auto enumerate() { - return make_view_factory([](auto&& range) { + return ViewFactory{[](auto&& range) { using Range = decltype(range); return EnumerateView>{std::forward(range)}; - }); + }}; } template @@ -255,10 +254,10 @@ struct TransformView template inline auto transform(Transform t) { - return make_view_factory([t = std::move(t)](auto&& range) { + return ViewFactory{[t = std::move(t)](auto&& range) { using Range = decltype(range); return TransformView, Transform>{std::forward(range), std::move(t)}; - }); + }}; } template @@ -363,28 +362,28 @@ struct SplitView template auto split(Element separator) { - return make_view_factory([s = std::move(separator)](auto&& range) { + return ViewFactory{[s = std::move(separator)](auto&& range) { using Range = decltype(range); return SplitView, false, false, Element, ValueType>{std::forward(range), std::move(s), {}}; - }); + }}; } template auto split_after(Element separator) { - return make_view_factory([s = std::move(separator)](auto&& range) { + return ViewFactory{[s = std::move(separator)](auto&& range) { using Range = decltype(range); return SplitView, false, true, Element, ValueType>{std::forward(range), std::move(s), {}}; - }); + }}; } template auto split(Element separator, Element escaper) { - return make_view_factory([s = std::move(separator), e = std::move(escaper)](auto&& range) { + return ViewFactory{[s = std::move(separator), e = std::move(escaper)](auto&& range) { using Range = decltype(range); return SplitView, true, false, Element, ValueType>{std::forward(range), std::move(s), std::move(e)}; - }); + }}; } template @@ -518,26 +517,26 @@ void for_n_best(Range&& c, size_t count, Compare&& compare, Func&& func) template auto gather() { - return make_view_factory([](auto&& range) { + return ViewFactory{[](auto&& range) { using std::begin; using std::end; return Container(begin(range), end(range)); - }); + }}; } template