util/TemplateString: add FromLiteral()

This commit is contained in:
Max Kellermann 2020-10-23 13:00:44 +02:00 committed by Max Kellermann
parent b8df851414
commit ad2c22844c

View File

@ -108,6 +108,18 @@ copy_n(const char *src, std::size_t n, char *dest) noexcept
}
/**
* A string consisting of a single character.
*/
template<std::size_t size>
constexpr auto
FromLiteral(const char (&src)[size]) noexcept
{
Buffer<size - 1> result{};
detail::copy_n(src, result.size, result.value);
return result;
}
template<typename... Args>
constexpr auto
Concat(Args... args) noexcept