summaryrefslogtreecommitdiff
path: root/src/string.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-06-06 08:50:51 +0100
committerMaxime Coste <mawww@kakoune.org>2017-06-06 08:50:51 +0100
commit36364d5f6b8193230182684dd1736bd83643ff2d (patch)
treecff593f24c9c58a29c6a0da546df49de1ee3d027 /src/string.hh
parent8794687f36651e56a26b97e2f5d405e092b462c6 (diff)
Fix spurious copies being made when using the format function
We were not correctly forwarding the arguments, leading to copies of 'const String&' parameters.
Diffstat (limited to 'src/string.hh')
-rw-r--r--src/string.hh8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/string.hh b/src/string.hh
index cae9b170..056db814 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -418,17 +418,17 @@ StringView format_param(const T& val) { return val; }
String format(StringView fmt, ArrayView<const StringView> params);
template<typename... Types>
-String format(StringView fmt, Types... params)
+String format(StringView fmt, Types&&... params)
{
- return format(fmt, ArrayView<const StringView>{detail::format_param(params)...});
+ return format(fmt, ArrayView<const StringView>{detail::format_param(std::forward<Types>(params))...});
}
StringView format_to(ArrayView<char> buffer, StringView fmt, ArrayView<const StringView> params);
template<typename... Types>
-StringView format_to(ArrayView<char> buffer, StringView fmt, Types... params)
+StringView format_to(ArrayView<char> buffer, StringView fmt, Types&&... params)
{
- return format_to(buffer, fmt, ArrayView<const StringView>{detail::format_param(params)...});
+ return format_to(buffer, fmt, ArrayView<const StringView>{detail::format_param(std::forward<Types>(params))...});
}
}