The open source OpenXR runtime

a/util: Add clear() method to HistoryBuffer

+21
+11
src/xrt/auxiliary/util/u_template_historybuf.hpp
··· 178 178 const T & 179 179 back() const; 180 180 181 + void 182 + clear(); 183 + 181 184 private: 182 185 // Make sure all valid indices can be represented in a signed integer of the same size 183 186 static_assert(MaxSize < (std::numeric_limits<size_t>::max() >> 1), "Cannot use most significant bit"); ··· 186 189 container_t internalBuffer{}; 187 190 detail::RingBufferHelper helper_{MaxSize}; 188 191 }; 192 + 193 + 194 + template <typename T, size_t MaxSize> 195 + void 196 + HistoryBuffer<T, MaxSize>::clear() 197 + { 198 + helper_.clear(); 199 + } 189 200 190 201 template <typename T, size_t MaxSize> 191 202 inline bool
+10
src/xrt/auxiliary/util/u_template_historybuf_impl_helpers.hpp
··· 113 113 size_t 114 114 back_inner_index() const noexcept; 115 115 116 + void 117 + clear(); 118 + 116 119 private: 117 120 // Would be const, but that would mess up our ability to copy/move containers using this. 118 121 size_t capacity_; ··· 134 137 front_impl_() const noexcept; 135 138 }; 136 139 140 + 141 + inline void 142 + RingBufferHelper::clear() 143 + { 144 + this->latest_inner_idx_ = 0; 145 + this->length_ = 0; 146 + } 137 147 138 148 inline size_t 139 149 RingBufferHelper::front_impl_() const noexcept