util/TemplateString: add cast operators

This commit is contained in:
Max Kellermann
2020-10-23 12:56:49 +02:00
committed by Max Kellermann
parent 02314ac7dd
commit 3af35aee9e
3 changed files with 15 additions and 6 deletions

View File

@@ -32,6 +32,7 @@
#include <array> // for std::size()
#include <cstddef>
#include <string_view>
namespace TemplateString {
@@ -39,6 +40,14 @@ template<std::size_t _size>
struct Buffer {
static constexpr std::size_t size = _size;
char value[size + 1];
constexpr operator const char *() const noexcept {
return value;
}
constexpr operator std::string_view() const noexcept {
return {value, size};
}
};
/**