diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-12-28 10:47:16 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-12-28 10:47:16 +1100 |
| commit | 7c1d4f5bd61129530e30abd92c8f65893fdf8a93 (patch) | |
| tree | 8405c29c50456e9acea3a3ad3a9412635caaee93 /src | |
| parent | 456fbd1315d99276b4b5edbafb6fbd78c513a6e6 (diff) | |
Avoid unnecessary std::function
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/commands.cc b/src/commands.cc index 2d5b2d81..a0ac6777 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -175,10 +175,11 @@ static Completions complete_buffer_name(const Context& context, CompletionFlags return { 0, cursor_pos, res }; } -auto make_single_word_completer(std::function<String (const Context&)> func) +template<typename Func> +auto make_single_word_completer(Func&& func) { return make_completer( - [func](const Context& context, CompletionFlags flags, + [func = std::move(func)](const Context& context, CompletionFlags flags, const String& prefix, ByteCount cursor_pos) -> Completions { auto candidate = { func(context) }; return { 0_byte, cursor_pos, complete(prefix, cursor_pos, candidate) }; }); |
