Squashed 'deps/nostalgia/' changes from 10a12f2a..59fa3907

59fa3907 [keel] Update pack for Preloader changes
c55994f6 [ox/std] Add Vector::capacity
e81d28a6 [ox] Fix various preloader problems
0626c2a8 [ox/fs] Add comparison operator for FileAddress

git-subtree-dir: deps/nostalgia
git-subtree-split: 59fa39070f0c93be71060afb2584608e90cef84f
This commit is contained in:
2024-02-01 21:07:56 -06:00
parent 0d61e5a064
commit 8e0467ca5f
8 changed files with 82 additions and 24 deletions

View File

@@ -20,7 +20,7 @@ namespace ox {
template<OxString_c Str>
[[nodiscard]]
constexpr ox::StringView substr(Str const&str, std::size_t pos) noexcept {
constexpr Str substr(Str const&str, std::size_t pos) noexcept {
if (str.len() >= pos) {
return Str(str.data() + pos, str.len() - pos);
}

View File

@@ -239,6 +239,9 @@ class Vector: detail::VectorAllocator<T, Allocator, SmallVectorSize> {
[[nodiscard]]
constexpr Result<const T*> back() const noexcept;
[[nodiscard]]
constexpr std::size_t capacity() const noexcept;
[[nodiscard]]
constexpr std::size_t size() const noexcept;
@@ -424,7 +427,7 @@ constexpr const T &Vector<T, SmallVectorSize, Allocator>::operator[](std::size_t
template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr Result<T*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) noexcept {
if (i < size()) {
if (i < size()) [[likely]] {
return &operator[](i);
}
return OxError(1, "Vector: Invalid index");
@@ -432,7 +435,7 @@ constexpr Result<T*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) noexcep
template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr Result<T const*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) const noexcept {
if (i < size()) {
if (i < size()) [[likely]] {
return &operator[](i);
}
return OxError(1, "Vector: Invalid index");
@@ -470,6 +473,11 @@ constexpr Result<const T*> Vector<T, SmallVectorSize, Allocator>::back() const n
return &m_items[m_size - 1];
}
template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr std::size_t Vector<T, SmallVectorSize, Allocator>::capacity() const noexcept {
return m_cap;
}
template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr std::size_t Vector<T, SmallVectorSize, Allocator>::size() const noexcept {
return m_size;