Skip to content

Typed fixed vector#737

Draft
wvpm wants to merge 6 commits into
masterfrom
typed_fixed_vector
Draft

Typed fixed vector#737
wvpm wants to merge 6 commits into
masterfrom
typed_fixed_vector

Conversation

@wvpm
Copy link
Copy Markdown
Contributor

@wvpm wvpm commented May 15, 2026

  1. Support strongly typed indices in FixedVector
  2. Use index as key instead of pointers
  3. Use FixedVector instead of IndexFlatMap when the key isn't required (only index and value)
  4. Improve FixedVector constructors to be explicit and support moving the vector itself (not the values).

@wvpm wvpm force-pushed the typed_fixed_vector branch 2 times, most recently from ebff5ff to 1dd904b Compare May 16, 2026 16:40
@wvpm wvpm force-pushed the typed_fixed_vector branch from 1dd904b to cc9a1a8 Compare May 16, 2026 17:26
@wvpm wvpm force-pushed the typed_fixed_vector branch from 91ba5c1 to c85cc3e Compare May 16, 2026 20:00
@wvpm wvpm force-pushed the typed_fixed_vector branch from 4e64a63 to 3564f97 Compare May 16, 2026 20:20
Comment on lines +15 to +16
struct create_empty_t { };
struct generate_values_t { };
Copy link
Copy Markdown
Member

@Spartan322 Spartan322 May 16, 2026

Choose a reason for hiding this comment

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

Suggested change
struct create_empty_t { };
struct generate_values_t { };
struct create_empty_t { };
static consexpr create_empty_t create_empty {};
struct generate_values_t { };
static constexpr generate_values_t generate_values {};

Than you can do create_empty and generate_values instead of create_empty_t {} and generate_values_t {}.

std::fill(_data_start_ptr, _data_start_ptr + get_index_as_size_t(size), value_for_all_indices);
}

constexpr explicit FixedVector(const size_type capacity, generate_values_t)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In C++ its usually preferred for the tag to come first so

Suggested change
constexpr explicit FixedVector(const size_type capacity, generate_values_t)
constexpr explicit FixedVector(generate_values_t, const size_type capacity)

* @brief Creates an uninitialised vector with fixed capacity
*/
constexpr explicit FixedVector(const size_t capacity)
constexpr explicit FixedVector(const size_type capacity, create_empty_t)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In C++ its usually preferred for the tag to come first so

Suggested change
constexpr explicit FixedVector(const size_type capacity, create_empty_t)
constexpr explicit FixedVector(create_empty_t, const size_type capacity)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants