From ad2c22844cafff296147f50fe9f0a810454093fe Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 23 Oct 2020 13:00:44 +0200 Subject: [PATCH] util/TemplateString: add FromLiteral() --- src/util/TemplateString.hxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util/TemplateString.hxx b/src/util/TemplateString.hxx index 0c034fbba..447992242 100644 --- a/src/util/TemplateString.hxx +++ b/src/util/TemplateString.hxx @@ -108,6 +108,18 @@ copy_n(const char *src, std::size_t n, char *dest) noexcept } +/** + * A string consisting of a single character. + */ +template +constexpr auto +FromLiteral(const char (&src)[size]) noexcept +{ + Buffer result{}; + detail::copy_n(src, result.size, result.value); + return result; +} + template constexpr auto Concat(Args... args) noexcept