Skip to content

Commit

Permalink
utlvector.h fix assert
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Jan 31, 2024
1 parent 4b49f63 commit 2d957a7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions regamedll/public/utlvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ class CUtlVector
CUtlVector(T *pMemory, int numElements);
~CUtlVector();

// features C++11 ranged based for
T *begin() { return &m_Memory[0]; }
T *end() { return &m_Memory[m_Size]; }

T const *begin() const { return &m_Memory[0]; }
T const *end() const { return &m_Memory[m_Size]; }

// Copy the array.
CUtlVector<T> &operator=(const CUtlVector<T> &other);

Expand All @@ -59,6 +52,13 @@ class CUtlVector
T &Element(int i);
T const &Element(int i) const;

// STL compatible member functions. These allow easier use of std::sort
// and they are forward compatible with the C++ 11 range-based for loops
T *begin() { return Base(); }
const T *begin() const { return Base(); }
T *end() { return Base() + Count(); }
const T *end() const { return Base() + Count(); }

// Gets the base address (can change when adding elements!)
T *Base();
T const *Base() const;
Expand Down Expand Up @@ -583,13 +583,13 @@ void CUtlVector<T>::SetGrowSize(int size)
template <class T>
void CUtlVector<T>::Sort()
{
std::sort(Base(), Base() + Count());
std::sort(begin(), end());
}

template <class T>
void CUtlVector<T>::Sort(bool (*pfnLessFunc)(const T &src1, const T &src2))
{
std::sort(Base(), Base() + Count(),
std::sort(begin(), end(),
[pfnLessFunc](const T &a, const T &b) -> bool
{
if (&a == &b)
Expand Down Expand Up @@ -628,5 +628,5 @@ template <class T>
template <class F>
void CUtlVector<T>::SortPredicate(F &&predicate)
{
std::sort(Base(), Base() + Count(), predicate);
std::sort(begin(), end(), predicate);
}

0 comments on commit 2d957a7

Please sign in to comment.