feat(vector): revamped vector implementation #1

Merged
xbazzi merged 10 commits from atrecio/fastinahurry:master into master 2026-07-04 15:02:55 -04:00
Contributor
No description provided.
Owner

Left some minor comments regarding bugs and missing stuff. Thank you for the changes, this is a much needed and overdue makeover.

Left some minor comments regarding bugs and missing stuff. Thank you for the changes, this is a much needed and overdue makeover.
xbazzi left a comment

Let's fix these and I'll clone again to run tests.

Let's fix these and I'll clone again to run tests.
@ -19,2 +24,3 @@
static Element *_allocate(std::uint64_t alloc_size)
T* m_begin{nullptr};
T* m_size{0};
Owner

rename to m_end, pretty please

rename to m_end, pretty please
@ -23,2 +31,2 @@
return nullptr;
return static_cast<Element *>(::operator new(sizeof(Element) * alloc_size));
assert(alloc_size != 0);
return static_cast<T*>(::operator new(TSize * alloc_size, TAlign));
Owner

You're not matching the call to the right operator delete overload, but I'm not sure that matters at all. Might be UB, idk

You're not matching the call to the right operator delete overload, but I'm not sure that matters at all. Might be UB, idk
@ -47,0 +43,4 @@
std::destroy_n(m_begin, curr_sz);
::operator delete(m_begin);
m_begin = new_arr;
Owner

Missing m_size = curr_sz;

Missing m_size = curr_sz;
Author
Contributor

that doesn't do anything you (beautiful person)

that doesn't do anything you (beautiful person)
@ -47,0 +48,4 @@
}
constexpr void _allocate_from_empty(std::size_t new_cap = 1) noexcept
{
Owner

Missing m_size = m_begin;

Missing m_size = m_begin;
@ -77,1 +81,3 @@
::operator delete(p_arr);
if(empty()) _allocate_from_empty();
else if (m_size == m_cap) _grow_capacity(capacity() * ExpansionMult);
return *std::construct_at(m_size++, std::forward<Args>(args)...);
Owner

we talked about not caring about exception safety, so I'll just make a comment that we're advancing size without knowing if ctor will succeed. Oh well, I'm ok with that

we talked about not caring about exception safety, so I'll just make a comment that we're advancing size without knowing if ctor will succeed. Oh well, I'm ok with that
@ -61,2 +69,4 @@
constexpr Vector(ReserveInitial<N>) noexcept
{
_allocate_from_empty(N);
}
Owner

I'm not gonna make you do rule of 5, but could you please add a default ctor? 👉👈

I'm not gonna make you do rule of 5, but could you please add a default ctor? 👉👈
Author
Contributor

there is one you (beautiful person). but i'm going to add rule of 5 anyways because you're such a (beautiful person).

there is one you (beautiful person). but i'm going to add rule of 5 anyways because you're such a (beautiful person).
@ -134,3 +116,3 @@
}
void shrink_to_fit()
constexpr void resize(std::size_t new_cap) noexcept
Owner

Rename to reserve()

Rename to reserve()
Author
Contributor

reserve and resize do two different things but i'll add reserve anyways you (beautiful person)

reserve and resize do two different things but i'll add reserve anyways you (beautiful person)
@ -143,2 +129,3 @@
{
m_cap = new_cap;
assert(not empty());
std::destroy_at(m_size--);
Owner

We might be destroying past end

We might be destroying past end
Author
Contributor

for once you're right

for once you're right
@ -0,0 +1,9 @@
#include <cstdint>
Owner

header guard where?

header guard where?
@ -0,0 +1,9 @@
#include <cstdint>
namespace fiah {
Owner

extremely pedantic redditor comment: std:: integral types are under cstddef, not cstdint

extremely pedantic redditor comment: std:: integral types are under cstddef, not cstdint
xbazzi approved these changes 2026-06-28 08:26:09 -04:00
xbazzi left a comment

fix issue below + conflicts and I will merge. thank you

fix issue below + conflicts and I will merge. thank you
@ -57,0 +64,4 @@
constexpr void _free() noexcept
{
::operator delete(m_begin, TAlign);
m_begin = m_end = m_begin = nullptr;
Owner

🤔

🤔
atrecio marked this conversation as resolved
Owner

Please ensure title follows conventional commit style

Please ensure title follows conventional commit style
atrecio changed title from revamped vector and added type flags to FEAT: (vector, type flags) 2026-07-04 15:01:26 -04:00
xbazzi changed title from FEAT: (vector, type flags) to feat(vector): revamped vector implementation 2026-07-04 15:01:52 -04:00
xbazzi approved these changes 2026-07-04 15:02:44 -04:00
xbazzi left a comment

LGTM 😛

LGTM 😛
@ -1,0 +5,4 @@
// If C++: Your code is automatically compiled with a precompiled header. //
// 99% of includes / packages are already added for you. //
// You do NOT need to add your own includes here. //
// /////////////////////////////////////////////////////////////////////////
Owner

this header was removed in my master. Please pull properly

this header was removed in my master. Please pull properly
@ -201,3 +209,3 @@
};
} // namespace fiah
<<<<<<< HEAD
Owner

pls remove and solve conflicts properly

pls remove and solve conflicts properly
@ -204,0 +228,4 @@
std::cout << anotherone.use_count() << " ";
}
>>>>>>> 0256ede (added header guards where missing, updated /fixed vector issues)
Owner

oof

oof
xbazzi merged commit 6fbd15a8fd into master 2026-07-04 15:02:55 -04:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
xbazzi/fastinahurry!1
No description provided.