Skip to content

Commit

Permalink
Fix cicular_q::size()
Browse files Browse the repository at this point in the history
  • Loading branch information
eudoxos committed Nov 9, 2019
1 parent 6f0cb63 commit bad7284
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion include/spdlog/details/circular_q.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ class circular_q
// Return number of elements actually stored
size_t size() const
{
return (tail_ - head_) % max_items_;
if (tail_ > head_)
{
return (tail_ - head_) % max_items;
}
else
{
return max_items - (head_ - tail_ ) % max_items;
}
}

// Return const reference to item by index.
Expand Down

0 comments on commit bad7284

Please sign in to comment.