Add const version of NewsItemQueue::operator[]

This commit is contained in:
hdpoliveira 2020-05-30 14:37:58 -03:00
parent b519247bad
commit a94fc10c77
2 changed files with 6 additions and 0 deletions

View File

@ -75,6 +75,11 @@ NewsItem* news_item_get(int32_t index)
}
NewsItem& NewsItemQueue::operator[](size_t index)
{
return const_cast<NewsItem&>(const_cast<const NewsItemQueue&>(*this)[index]);
}
const NewsItem& NewsItemQueue::operator[](size_t index) const
{
if (index < NEWS_ITEM_HISTORY_START)
return Recent[index];

View File

@ -68,6 +68,7 @@ extern const uint8_t news_type_properties[10];
struct NewsItemQueue
{
NewsItem& operator[](size_t index);
const NewsItem& operator[](size_t index) const;
NewsItem* At(int32_t index);
const NewsItem* At(int32_t index) const;
bool IsEmpty() const;