@@ -13,36 +13,34 @@ namespace sunstone_rtls {
1313 template <typename T, std::size_t Capacity>
1414 class static_ring_vector {
1515 public:
16- typedef T value_type;
17- typedef T *pointer;
18- typedef T &reference;
19- typedef T const &const_reference;
20- typedef T const *const_pointer;
21-
22- typedef std::size_t size_type;
23-
24- typedef detail::static_ring_iterator<T , Capacity> iterator;
25- typedef detail::static_ring_iterator<const T, Capacity> const_iterator;
26-
27- typedef std::reverse_iterator<iterator > reverse_iterator;
28- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
16+ using value_type = T;
17+ using pointer = T*;
18+ using reference = T&;
19+ using const_reference = T const &;
20+ using const_pointer = T const *;
21+ using size_type = std::size_t ;
22+ using container_type = std::array<std::aligned_storage_t <sizeof (T), alignof (T)>, Capacity>;
23+
24+ using iterator = detail::static_ring_iterator<T , Capacity>;
25+ using const_iterator = detail::static_ring_iterator<const T, Capacity>;
26+ using reverse_iterator = std::reverse_iterator<iterator >;
27+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
2928
3029 // construct + assign
31- static_ring_vector () noexcept : m_begin(begin_capacity()), m_size{} {} ;
30+ static_ring_vector () noexcept = default ;
3231
3332 template <typename InputIt>
34- static_ring_vector (InputIt begin, InputIt end)
35- : static_ring_vector() {
33+ static_ring_vector (InputIt begin, InputIt end, typename std::iterator_traits<InputIt>::iterator_category* = nullptr ) noexcept (noexcept (T(*begin))) {
3634 assign (begin, end);
3735 }
3836
3937 explicit static_ring_vector (size_type count) noexcept (noexcept (T()))
40- : m_begin(begin_capacity()), m_size{std::min (count, Capacity)} {
38+ : m_size{std::min (count, Capacity)} {
4139 std::uninitialized_default_construct_n (m_begin, m_size);
4240 }
4341
4442 explicit static_ring_vector (size_type count, const_reference value) noexcept (noexcept (T(value)))
45- : m_begin(begin_capacity()), m_size{std::min (count, Capacity)} {
43+ : m_size{std::min (count, Capacity)} {
4644 std::uninitialized_fill_n (m_begin, m_size, value);
4745 }
4846
@@ -231,7 +229,7 @@ namespace sunstone_rtls {
231229 return *this ;
232230 }
233231
234- It operator ++(int ) {
232+ const It operator ++(int ) {
235233 It cp (*this );
236234 ++*this ;
237235 return cp;
@@ -396,19 +394,19 @@ namespace sunstone_rtls {
396394 }
397395
398396 private:
399- inline auto begin_capacity () const {
397+ inline auto begin_capacity () const noexcept {
400398 return reinterpret_cast <const_pointer>(rawData.data ());
401399 }
402400
403- inline auto begin_capacity () {
401+ inline auto begin_capacity () noexcept {
404402 return reinterpret_cast <pointer>(rawData.data ());
405403 }
406404
407- inline auto end_capacity () const {
405+ inline auto end_capacity () const noexcept {
408406 return begin_capacity () + Capacity;
409407 }
410408
411- inline auto end_capacity () {
409+ inline auto end_capacity () noexcept {
412410 return begin_capacity () + Capacity;
413411 }
414412
@@ -597,16 +595,21 @@ namespace sunstone_rtls {
597595 push_back (*first);
598596 }
599597
600- std::array<std:: aligned_storage_t < sizeof (T), alignof (T)>, Capacity> rawData;
601- pointer m_begin;
598+ container_type rawData;
599+ pointer m_begin{ begin_capacity ()} ;
602600 size_type m_size{};
603601 };
604602
605603 namespace detail {
606604 template <typename T, std::size_t Capacity>
607- class static_ring_iterator : public std ::iterator_traits<T*>, public std:: tuple<typename std::iterator_traits<T*>::difference_type> {
605+ class static_ring_iterator : public std ::tuple<typename std::iterator_traits<T*>::difference_type> {
608606 public:
609- using difference_type = typename std::iterator_traits<T*>::difference_type;
607+ using iterator_category = typename std::iterator_traits<T*>::iterator_category;
608+ using value_type = typename std::iterator_traits<T*>::value_type;
609+ using difference_type = typename std::iterator_traits<T*>::difference_type;
610+ using pointer = typename std::iterator_traits<T*>::pointer;
611+ using reference = typename std::iterator_traits<T*>::reference;
612+
610613 static_ring_iterator () = default ;
611614 static_ring_iterator (const static_ring_iterator&) = default ;
612615 static_ring_iterator (static_ring_iterator&&) noexcept = default ;
@@ -630,7 +633,7 @@ namespace sunstone_rtls {
630633 return *this ;
631634 }
632635
633- static_ring_iterator operator ++(int ) {
636+ const static_ring_iterator operator ++(int ) {
634637 static_ring_iterator cp (*this );
635638 ++*this ;
636639 return cp;
@@ -641,7 +644,7 @@ namespace sunstone_rtls {
641644 return *this ;
642645 }
643646
644- static_ring_iterator operator --(int ) {
647+ const static_ring_iterator operator --(int ) {
645648 static_ring_iterator cp (*this );
646649 --*this ;
647650 return cp;
0 commit comments