diff --git a/src/core/ring_buffer.hpp b/src/core/ring_buffer.hpp index 837173ae43..8593be1228 100644 --- a/src/core/ring_buffer.hpp +++ b/src/core/ring_buffer.hpp @@ -252,6 +252,24 @@ public: } } + template ::iterator_category, std::input_iterator_tag>::value>> + ring_buffer(InputIt first, InputIt last) + { + if (first == last) return; + + uint32_t size = (uint32_t)std::distance(first, last); + uint32_t cap = round_up_size(size); + this->data.reset(MallocT(cap * sizeof(T))); + this->mask = cap - 1; + this->head = 0; + this->count = size; + uint8_t *ptr = this->data.get(); + for (auto iter = first; iter != last; ++iter) { + new (ptr) T(*iter); + ptr += sizeof(T); + } + } + ring_buffer& operator =(const ring_buffer &other) { if (&other != this) {