forked from Ferdi265/cxx-ring-buffer
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
d9314150c2 | |||
5a6309dc28 | |||
795a4c3be7 | |||
5a021c46d0 |
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) [year] [fullname]
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -41,6 +41,10 @@ public:
|
||||
return {*container_ptr, front, index - n};
|
||||
}
|
||||
|
||||
CONSTEXPR difference_type operator-(const ring_buffer_iterator& other) const NOEXCEPT {
|
||||
return index - other.index;
|
||||
}
|
||||
|
||||
CONSTEXPR reference operator*() COND_NOEXCEPT(noexcept(container_ptr->begin()) && noexcept(container_ptr->size())) {
|
||||
return *(container_ptr->begin() + (front + index) % container_ptr->size());
|
||||
}
|
||||
@ -90,7 +94,7 @@ public:
|
||||
return index >= other.index;
|
||||
}
|
||||
|
||||
CONSTEXPR friend ring_buffer_iterator operator+( difference_type n, const ring_buffer_iterator& it) NOEXCEPT {
|
||||
CONSTEXPR friend ring_buffer_iterator operator+(difference_type n, const ring_buffer_iterator& it) NOEXCEPT {
|
||||
return it + n;
|
||||
}
|
||||
CONSTEXPR friend void swap(ring_buffer_iterator& a, ring_buffer_iterator& b) COND_NOEXCEPT(noexcept(std::swap(a.container, b.container))) {
|
||||
@ -137,6 +141,10 @@ public:
|
||||
return {*container_ptr, front, index - n};
|
||||
}
|
||||
|
||||
CONSTEXPR difference_type operator-(const ring_buffer_const_iterator& other) const NOEXCEPT {
|
||||
return index - other.index;
|
||||
}
|
||||
|
||||
CONSTEXPR reference operator*() const COND_NOEXCEPT(noexcept(container_ptr->cbegin()) && noexcept(container_ptr->size())) {
|
||||
return *(container_ptr->cbegin() + (front + index) % container_ptr->size());
|
||||
}
|
||||
@ -186,7 +194,7 @@ public:
|
||||
return index >= other.index;
|
||||
}
|
||||
|
||||
CONSTEXPR friend ring_buffer_const_iterator operator+( difference_type n, const ring_buffer_const_iterator& it) NOEXCEPT {
|
||||
CONSTEXPR friend ring_buffer_const_iterator operator+(difference_type n, const ring_buffer_const_iterator& it) NOEXCEPT {
|
||||
return it + n;
|
||||
}
|
||||
CONSTEXPR friend void swap(ring_buffer_const_iterator& a, ring_buffer_const_iterator& b) COND_NOEXCEPT(noexcept(std::swap(a.container, b.container))) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#if defined( __cpp_lib_array_constexpr) && __cpp_lib_array_constexpr >= 201606L
|
||||
template <typename T, size_t N>
|
||||
using constexpr_array = array;
|
||||
using constexpr_array = std::array<T, N>;
|
||||
#else
|
||||
template <typename T, size_t N>
|
||||
struct constexpr_array {
|
||||
|
Reference in New Issue
Block a user