From 63dc75fb81a54d0271236deb1bc1ec24c7431398 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 --- modules/beast_core/memory/beast_MemoryBlock.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/beast_core/memory/beast_MemoryBlock.h b/modules/beast_core/memory/beast_MemoryBlock.h index 103f885ac0..e8ec6949d1 100644 --- a/modules/beast_core/memory/beast_MemoryBlock.h +++ b/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; }