Add compile-time checked value constructor to path

This commit is contained in:
kayomn 2023-02-19 14:14:43 +00:00
parent 51b73aa823
commit 22a8b63d0f
1 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,12 @@ export namespace core {
this->buffer[max] = max;
}
template<usize text_size> 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.
*/