Added private get function to preserve constness of at()
This commit is contained in:
@@ -131,16 +131,9 @@ public:
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
auto at(qsizetype index) -> T
|
||||
auto at(qsizetype index) const -> T
|
||||
{
|
||||
QMutexLocker dataLocker(&m_dataMutex);
|
||||
|
||||
if(index < 0 || index >= m_data.count())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return m_data.at(index);
|
||||
return get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,6 +257,25 @@ protected:
|
||||
}
|
||||
|
||||
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
|
||||
* Current absolute offset. Used in fetch operations
|
||||
|
||||
Reference in New Issue
Block a user