Skip to content

Add tunable_vector std::vector wrapper container#746

Draft
Spartan322 wants to merge 2 commits into
add/stl-like-containersfrom
add/tunable-vector
Draft

Add tunable_vector std::vector wrapper container#746
Spartan322 wants to merge 2 commits into
add/stl-like-containersfrom
add/tunable-vector

Conversation

@Spartan322
Copy link
Copy Markdown
Member

@Spartan322 Spartan322 commented May 20, 2026

Add tunable_vector memory alias to core/memory

@Spartan322 Spartan322 added enhancement New feature or request topic:core labels May 20, 2026
@Spartan322 Spartan322 force-pushed the add/stl-like-containers branch from 0c289ed to b2c561e Compare May 20, 2026 16:39
@Spartan322 Spartan322 force-pushed the add/tunable-vector branch from d00c51f to 27db712 Compare May 20, 2026 16:40
@wvpm
Copy link
Copy Markdown
Contributor

wvpm commented May 20, 2026

Add tunable_vector memory alias to core/memory

It shouldn't depend on that based on the code I read.
And it adds the entire type, not merely an alias.
Still nice draft.

Comment thread src/openvic-simulation/core/stl/containers/TunableVector.hpp Outdated
constexpr void append_range(RangeT&& range) {
if constexpr (std::ranges::forward_range<RangeT> || std::ranges::sized_range<RangeT>) {
reserve_minimum(std::ranges::distance(range));
std::ranges::move(range, std::back_inserter(*this));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ranges v3?
or std::uninitialized_copy + resize?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do uninitialized_copy, would require handling allocations manually, which I could do, but I'd rather defer that for later unless requested.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought there was a cross platform issue with ranges and that's why we generaly use ranges v3, is that no longer the case?

Comment thread src/openvic-simulation/core/stl/containers/TunableVector.hpp
}

if (value > new_capacity) {
return value;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong.
Say you reserve for value and fill it to or near value then add 1-3 elements, it would have to reallocate again.
It would make more sense if it:

  • reserves for value + buffer size
  • reserves for value x factor
  • reserves for smallest factor^n that fits value (+ buffer)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only specifically in the case that you reserve more than the next factor size, this is what all the standard libraries will do with resize.

@Spartan322 Spartan322 force-pushed the add/stl-like-containers branch 3 times, most recently from d4bc84c to db3fe7f Compare May 20, 2026 20:14
@Spartan322 Spartan322 force-pushed the add/tunable-vector branch from 27db712 to 9516014 Compare May 20, 2026 20:16
@Spartan322 Spartan322 force-pushed the add/stl-like-containers branch from db3fe7f to f94003a Compare May 20, 2026 22:57
@Spartan322
Copy link
Copy Markdown
Member Author

Add tunable_vector memory alias to core/memory

It shouldn't depend on that based on the code I read. And it adds the entire type, not merely an alias. Still nice draft.

It doesn't rely on any code from there but I set it to depend specifically because it relies on the organization from that PR. Also the alias description is saying what its doing, it does add a memory alias for the tunable_vector type, that's that is going on in core/memory

@Spartan322 Spartan322 force-pushed the add/tunable-vector branch 3 times, most recently from c6fa092 to 900c58b Compare May 20, 2026 23:26
@Spartan322 Spartan322 force-pushed the add/stl-like-containers branch from f94003a to 069ae75 Compare May 21, 2026 00:48
@Spartan322 Spartan322 force-pushed the add/tunable-vector branch from 900c58b to aa6c10a Compare May 21, 2026 00:49
@Spartan322 Spartan322 force-pushed the add/stl-like-containers branch from 069ae75 to ecb7ae0 Compare May 21, 2026 04:18
@Spartan322 Spartan322 force-pushed the add/tunable-vector branch from aa6c10a to f2b7c03 Compare May 21, 2026 04:19
@Spartan322 Spartan322 force-pushed the add/stl-like-containers branch from ecb7ae0 to b8ffe2c Compare May 21, 2026 04:30
Includes:
	- CowPtr
	- CowVector
	- FixedVector
	- RingBuffer
	- StackString
	- TypedSpan

Move allocator aware STL-like containers to `OpenVic::stl` namespace
Includes:
	- CowPtr
	- CowVector
	- FixedVector
	- RingBuffer

Move BasicIterator to `core/stl`
Move TslHelper.hpp to `core/stl` and rename to MutableIterator.hpp

Move memory container type aliases to `core/memory`

Add memory type alias for cow_ptr
Add memory type alias for cow_vector

Move FixedVector from namespace `OpenVic::_detail` to `OpenVic::stl`

Add stateful allocator support to FixedVector's constructors

Replace assert in TypedSpan with `OV_HARDEN_ASSERT_ACCESS`

Move STL-like container unit tests to `core/stl/containers`
Add tunable_vector memory alias to `core/memory`
@Spartan322 Spartan322 force-pushed the add/tunable-vector branch from f2b7c03 to 4e5d027 Compare May 21, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request topic:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants