[ox/std] Add Vector::capacity
This commit is contained in:
parent
e81d28a681
commit
c55994f67d
12
deps/ox/src/ox/std/vector.hpp
vendored
12
deps/ox/src/ox/std/vector.hpp
vendored
@ -239,6 +239,9 @@ class Vector: detail::VectorAllocator<T, Allocator, SmallVectorSize> {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr Result<const T*> back() const noexcept;
|
constexpr Result<const T*> back() const noexcept;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
constexpr std::size_t capacity() const noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr std::size_t size() const noexcept;
|
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>
|
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||||
constexpr Result<T*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) noexcept {
|
constexpr Result<T*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) noexcept {
|
||||||
if (i < size()) {
|
if (i < size()) [[likely]] {
|
||||||
return &operator[](i);
|
return &operator[](i);
|
||||||
}
|
}
|
||||||
return OxError(1, "Vector: Invalid index");
|
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>
|
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||||
constexpr Result<T const*> Vector<T, SmallVectorSize, Allocator>::at(size_t i) const noexcept {
|
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 &operator[](i);
|
||||||
}
|
}
|
||||||
return OxError(1, "Vector: Invalid index");
|
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];
|
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>
|
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||||
constexpr std::size_t Vector<T, SmallVectorSize, Allocator>::size() const noexcept {
|
constexpr std::size_t Vector<T, SmallVectorSize, Allocator>::size() const noexcept {
|
||||||
return m_size;
|
return m_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user