- Adjusted how asserts work and types of asserts

This commit is contained in:
2025-07-07 01:09:54 -04:00
parent 012052641d
commit 17d8218124
6 changed files with 152 additions and 71 deletions

View File

@@ -55,28 +55,12 @@ struct array
/// \name Element Access
/// @{
///
/// \copydetails array::at(size_t) const
constexpr ValueT& at(size_t i) { static_assert(i < ElemV); assert(i < ElemV, "Array Out of Bounds"); return elements[i]; }
///
/// \brief access specified element, **with bounds checking**
/// \details Returns a reference to the element at \c i
/// \param i index of the element to return
/// \return reference to the requested element
///
/// \par Time-Complexity
/// Constant
///
/// \par Space-Complexity
/// Constant
constexpr const ValueT& at(size_t i) const { static_assert(i < ElemV); assert(i < ElemV, "Array Out of Bounds"); return elements[i]; }
///
/// \copydetails array::operator[](size_t) const
constexpr ValueT& operator[](size_t i) { return elements[i]; }
constexpr ValueT& operator[](size_t i) {
assertd(i < ElemV, "Array Out of Bounds");
return elements[i];
}
///
/// \brief access specified element
@@ -89,7 +73,10 @@ struct array
///
/// \par Space-Complexity
/// Constant
constexpr const ValueT& operator[](size_t i) const { return elements[i]; }
constexpr const ValueT& operator[](size_t i) const {
assertd(i < ElemV, "Array Out of Bounds");
return elements[i];
}
/// @}