Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gabime/spdlog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVáclav Šmilauer <eu@doxos.eu>2019-11-09 11:30:27 +0300
committerVáclav Šmilauer <eu@doxos.eu>2019-11-09 11:30:27 +0300
commitbad728446564bc705ee5b348015a8ef0afcb7336 (patch)
tree05157eb4c5b56e802e0980dd4f700187caf94e6d /include
parent6f0cb6365ed6bb1c2fa6cf25b6f3471474b2ae0a (diff)
Fix cicular_q::size()
Diffstat (limited to 'include')
-rw-r--r--include/spdlog/details/circular_q.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/include/spdlog/details/circular_q.h b/include/spdlog/details/circular_q.h
index aac4223f..d07f0725 100644
--- a/include/spdlog/details/circular_q.h
+++ b/include/spdlog/details/circular_q.h
@@ -75,7 +75,14 @@ public:
// 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.