From 22a8b63d0f711b62ca7ef85716cae9b5627f26b8 Mon Sep 17 00:00:00 2001 From: kayomn Date: Sun, 19 Feb 2023 14:14:43 +0000 Subject: [PATCH] Add compile-time checked value constructor to path --- source/core/files.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/core/files.cpp b/source/core/files.cpp index c014fec..e71ab67 100644 --- a/source/core/files.cpp +++ b/source/core/files.cpp @@ -21,6 +21,12 @@ export namespace core { this->buffer[max] = max; } + template constexpr path(char const(&text)[text_size]) { + static_assert(text_size <= max, "path cannot be longer than maximum length"); + copy(this->buffer, text.as_bytes()); + zero(slice{this->buffer}.sliced(text_size, max - text_size)); + } + /** * Returns the base pointer of the path name. */