Added private get function to preserve constness of at()

This commit is contained in:
Digital Artifex
2026-06-08 22:42:49 -04:00
parent 8be07c47cb
commit a2afaf4401
+21 -9
View File
@@ -131,16 +131,9 @@ public:
* @param index * @param index
* @return * @return
*/ */
auto at(qsizetype index) -> T auto at(qsizetype index) const -> T
{ {
QMutexLocker dataLocker(&m_dataMutex); return get(index);
if(index < 0 || index >= m_data.count())
{
return {};
}
return m_data.at(index);
} }
/** /**
@@ -264,6 +257,25 @@ protected:
} }
private: private:
/**
* @brief get
* Private thread-safe get operation. This is needed to preserve the constness
* of the at function
* @param index
* @return
*/
auto get(qsizetype index) -> T
{
QMutexLocker dataLocker(&m_dataMutex);
if(index < 0 || index >= m_data.count())
{
return {};
}
return m_data.at(index);
}
/** /**
* @brief m_offset * @brief m_offset
* Current absolute offset. Used in fetch operations * Current absolute offset. Used in fetch operations