From da7627dd3bc0f0c9fd8d97980c3fc297653d0a58 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 9 Nov 2023 19:07:24 -0500 Subject: [PATCH] memory --- include/blt/std/memory.h | 70 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/include/blt/std/memory.h b/include/blt/std/memory.h index 7c4cfba..f36668d 100755 --- a/include/blt/std/memory.h +++ b/include/blt/std/memory.h @@ -102,6 +102,70 @@ namespace blt } } + template + struct range_itr + { + private: + const T current; + public: + using iterator_category = std::bidirectional_iterator_tag; + using difference_type = T; + using value_type = T; + using pointer = T*; + using reference = T&; + + explicit range_itr(T current): current(current) + {} + + value_type operator*() const + { return current; } + + value_type operator->() + { return current; } + + range_itr& operator++() + { + current++; + return *this; + } + + range_itr& operator--() + { + current--; + return *this; + } + + range_itr operator++(int) + { + auto tmp = *this; + ++(*this); + return tmp; + } + + range_itr operator--(int) + { + auto tmp = *this; + --(*this); + return tmp; + } + + friend bool operator==(const range_itr& a, const range_itr& b) + { + return a.current == b.current; + } + + friend bool operator!=(const range_itr& a, const range_itr& b) + { + return a.current != b.current; + } + }; + + template + struct range + { + + }; + template struct ptr_iterator { @@ -188,7 +252,8 @@ namespace blt scoped_buffer(const scoped_buffer& copy) { - if (copy.size() == 0) { + if (copy.size() == 0) + { _buffer = nullptr; _size = 0; return; @@ -216,7 +281,8 @@ namespace blt if (© == this) return *this; - if (copy.size() == 0) { + if (copy.size() == 0) + { _buffer = nullptr; _size = 0; return *this;