- Debugged more PrettyPrinters, all implemented thus far work in testing

- Fixed implementation of tuple.h, TODO: Still need to complete
 - Wrote a PrettyPrinter for tuple.h
This commit is contained in:
2025-08-10 23:46:36 -04:00
parent 9f96155856
commit b9de039a10
12 changed files with 170 additions and 44 deletions

View File

@@ -86,10 +86,10 @@ public:
///
/// \details adds additional character for null termination. Ignores whether str is null-terminated.
/// This constructor makes the assumption that `n` is the intended number of characters.
constexpr _string(const char* str, size_t n)
: _str(n + 1) {
constexpr _string(char* str, size_t n)
: _str(str[n - 1] == '\0' ? n : n + 1) {
fennec::memcpy(_str.data(), str, n);
_str[n] = '\0';
if (str[n - 1] != '\0') _str[n] = '\0';
}
///
@@ -97,7 +97,30 @@ public:
/// \param str the buffer to wrap
/// \tparam n the number of characters in the buffer plus the null terminator
template<size_t n>
constexpr _string(char(&str)[n])
explicit constexpr _string(char(&str)[n])
: _str(str, n) {
assert(_str[n - 1] == '\0', "Invalid NTBS.");
}
///
/// \brief Buffer Copy Constructor
/// \param str the buffer to copy
/// \param n number of characters in the buffer
///
/// \details adds additional character for null termination. Ignores whether str is null-terminated.
/// This constructor makes the assumption that `n` is the intended number of characters.
constexpr _string(const char* str, size_t n)
: _str(str[n - 1] == '\0' ? n : n + 1) {
fennec::memcpy(_str.data(), str, n);
if (str[n - 1] != '\0') _str[n] = '\0';
}
///
/// \brief Buffer Constructor, wraps the provided C-Style string
/// \param str the buffer to wrap
/// \tparam n the number of characters in the buffer plus the null terminator
template<size_t n>
explicit constexpr _string(const char(&str)[n])
: _str(str, n) {
assert(_str[n - 1] == '\0', "Invalid NTBS.");
}
@@ -385,7 +408,7 @@ public:
/// \returns
constexpr _string operator+(char c) const {
// Copy contents with one additional byte.
_string res(_str.data(), _str.size());
_string res(_str.data(), _str.size() + 1);
res[size()] = c; // Set the last character to c
return res;
}