C++20 Port #5

Merged
kayomn merged 35 commits from cpp-port into main 2023-02-20 02:33:45 +01:00
1 changed files with 7 additions and 5 deletions
Showing only changes of commit f6ae40617e - Show all commits

View File

@ -21,10 +21,12 @@ export namespace core {
this->buffer[max] = max;
}
template<usize text_size> constexpr path(char const(&text)[text_size]) {
template<usize text_size> constexpr path(char const(&text)[text_size]) : path{} {
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));
for (usize i = 0; i < text_size; i += 1) this->buffer[i] = text[i];
this->buffer[max] = max - text_size;
}
/**
@ -56,7 +58,7 @@ export namespace core {
* Returns the tail pointer of the path name.
*/
char const * end() const {
return reinterpret_cast<char const *>(this->buffer) + this->byte_size();
return this->buffer + this->byte_size();
}
/**
@ -96,7 +98,7 @@ export namespace core {
}
private:
u8 buffer[max + 1];
char buffer[max + 1];
};
/**