From 5e33606f1a77eba7484a95ae306d71b2eabf7cb6 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 1 Aug 2013 23:43:44 -0700 Subject: [PATCH] Add std container compatibility to MemoryBlock --- .../beast/modules/beast_core/memory/beast_MemoryBlock.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Subtrees/beast/modules/beast_core/memory/beast_MemoryBlock.h b/Subtrees/beast/modules/beast_core/memory/beast_MemoryBlock.h index 103f885ac..e8ec6949d 100644 --- a/Subtrees/beast/modules/beast_core/memory/beast_MemoryBlock.h +++ b/Subtrees/beast/modules/beast_core/memory/beast_MemoryBlock.h @@ -72,6 +72,14 @@ public: MemoryBlock& operator= (MemoryBlock&& other) noexcept; #endif + // Standard container interface + typedef char* iterator; + typedef char const* const_iterator; + inline iterator begin () noexcept { return static_cast (getData ()); } + inline iterator end () noexcept { return addBytesToPointer (begin (), size); } + inline const_iterator cbegin () const noexcept { return static_cast (getData ()); } + inline const_iterator cend () const noexcept { return addBytesToPointer (cbegin (), size); } + //============================================================================== /** Compares two memory blocks. @@ -104,7 +112,6 @@ public: template char& operator[] (const Type offset) const noexcept { return data [offset]; } - //============================================================================== /** Returns the block's current allocated size, in bytes. */ size_t getSize() const noexcept { return size; }