HNHacker News
TopNewBestAskShowJobs

_4r6j

1 karma · joined August 14, 2021

submissionscomments
_4r6j··on Show HN: C++ virtual_vec vector implementation
I believe you are talking about

*ptr = T(std::forward<Args>(args)...)

That's an rvalue ref so std::move is superfluous. Not an assign

_4r6j··on Show HN: C++ virtual_vec vector implementation
Someone added one for me https://github.com/keur/virtual_vec/pull/1 :)
_4r6j··on Show HN: C++ virtual_vec vector implementation
Yeah i verified the same thing on Linux. I will update the README with that.
_4r6j··on Show HN: C++ virtual_vec vector implementation
iterating over vectors (of trivial types that aren't pointers) is generally going to be faster since the memory is contiguous. deque is implemented with chunks i believe? loading in new chunk could be cache eviction.
_4r6j··on Show HN: C++ virtual_vec vector implementation
yeah it's not any better in that case then. i updated README to reflect that.
_4r6j··on Show HN: C++ virtual_vec vector implementation
good catch will update
_4r6j··on Show HN: C++ virtual_vec vector implementation
That will actually allocate 4GB to your process, EDIT: OS dependent. This just reserves 4GB of virtual memory addresses.
_4r6j··on Show HN: C++ virtual_vec vector implementation
If you know the size of your data upfront this isn't applicable. Usually I use std::vector when I don't know how much data I have. If you already know the size why not avoid allocating on the heap altogether? I will update the README to be more clear.