Skip to content

Conversation

@vabold
Copy link
Owner

@vabold vabold commented Jan 12, 2025

  • fixed_vector
  • owning_span

Closes #177.

Comment on lines +121 to +129
T &back() {
return *(m_data + m_size);
}

/// @brief Gets the last existing element in the array, or the first element if none exist.
/// @return The last existing element in the array.
const T &back() const {
return *(m_data + m_size);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you have an off-by-one error. back() should not return the same as end()

Suggested change
T &back() {
return *(m_data + m_size);
}
/// @brief Gets the last existing element in the array, or the first element if none exist.
/// @return The last existing element in the array.
const T &back() const {
return *(m_data + m_size);
}
T &back() {
return m_size > 0 ? *(m_data + m_size - 1) : *m_data;
}
/// @brief Gets the last existing element in the array, or the first element if none exist.
/// @return The last existing element in the array.
const T &back() const {
return m_size > 0 ? *(m_data + m_size - 1) : *m_data;
}

@vabold vabold added the P3 Priority: Low label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Priority: Low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explore viability/necessity for creating our own container types

3 participants