X-Git-Url: https://git.llucax.com/software/posixx.git/blobdiff_plain/3e4bff1a7e8e2d1f1ecb0f04440946b5eb78a591..e0bc5811a3c9726cc5b2dc804a7e8915c39d3dbd:/src/basic_buffer.hpp diff --git a/src/basic_buffer.hpp b/src/basic_buffer.hpp index 8180db8..1e53f96 100644 --- a/src/basic_buffer.hpp +++ b/src/basic_buffer.hpp @@ -6,6 +6,7 @@ #include // std::tr1::is_integral, true_type, false_type #include // std::memcpy(), memset(), memcmp() #include // assert() +#include // std::size_t, ptrdiff_t namespace posixx { @@ -35,16 +36,16 @@ struct basic_buffer { typedef const value_type& const_reference; /// - typedef value_type* iterator; // TODO: make a real iterator + typedef value_type* iterator; /// typedef const value_type* const_iterator; /// - typedef size_t size_type; + typedef std::size_t size_type; /// - typedef ptrdiff_t difference_type; + typedef std::ptrdiff_t difference_type; /// typedef value_type* pointer; @@ -53,12 +54,10 @@ struct basic_buffer { typedef const pointer const_pointer; /// - // TODO: reverse iterator - //typedef typename std::reverse_iterator< iterator > reverse_iterator; + typedef std::reverse_iterator< iterator > reverse_iterator; /// - //typedef typename std::reverse_iterator< const iterator > - // const_reverse_iterator; + typedef std::reverse_iterator< const_iterator > const_reverse_iterator; // Construct/Copy/Destroy @@ -178,29 +177,29 @@ struct basic_buffer { * Returns a random access reverse_iterator that points to the * past-the-end value. */ - //reverse_iterator rbegin() - //{ return std::reverse_iterator< iterator >(end()); } + reverse_iterator rbegin() + { return reverse_iterator(end()); } /** * Returns a random access const_reverse_iterator that points to the * past-the-end value. */ - //const_reverse_iterator rbegin() const - //{ return std::reverse_iterator< const iterator >(end()); } + const_reverse_iterator rbegin() const + { return const_reverse_iterator(end()); } /** * Returns a random access reverse_iterator that points to the first * element. */ - //reverse_iterator rend() - //{ return std::reverse_iterator< iterator >(begin()); } + reverse_iterator rend() + { return reverse_iterator(begin()); } /** * Returns a random access const_reverse_iterator that points to the * first element. */ - //const_reverse_iterator rend() const - //{ return std::reverse_iterator< const iterator >(begin()); } + const_reverse_iterator rend() const + { return const_reverse_iterator(begin()); } // Capacity @@ -434,10 +433,10 @@ protected: pointer _data; // Size in number of items - size_t _size; + std::size_t _size; // Allocator wrapper for automatic casting - static pointer _allocate(void* ptr, size_t sz) + static pointer _allocate(void* ptr, std::size_t sz) { if (ptr == NULL && sz == 0) return NULL; @@ -485,8 +484,9 @@ protected: /** * Returns true if x hass the same contents as y. */ -template < void* (*Allocator)(void*, size_t) > -bool operator == (const basic_buffer< Allocator >& x, const basic_buffer < Allocator >& y) +template < void* (*Allocator)(void*, std::size_t) > +bool operator == (const basic_buffer< Allocator >& x, + const basic_buffer < Allocator >& y) { if (&x == &y) return true; @@ -506,8 +506,9 @@ bool operator == (const basic_buffer< Allocator >& x, const basic_buffer < Alloc /** * Returns !(x==y). */ -template < void* (*Allocator)(void*, size_t) > -bool operator != (const basic_buffer& x, const basic_buffer & y) +template < void* (*Allocator)(void*, std::size_t) > +bool operator != (const basic_buffer& x, + const basic_buffer & y) { return !(x == y); } @@ -516,8 +517,9 @@ bool operator != (const basic_buffer& x, const basic_buffer -bool operator < (const basic_buffer< Allocator >& x, const basic_buffer< Allocator >& y) +template < void* (*Allocator)(void*, std::size_t) > +bool operator < (const basic_buffer< Allocator >& x, + const basic_buffer< Allocator >& y) { if (&x == &y) return false; @@ -537,8 +539,9 @@ bool operator < (const basic_buffer< Allocator >& x, const basic_buffer< Allocat /** * Returns y < x. */ -template < void* (*Allocator)(void*, size_t) > -bool operator > (const basic_buffer< Allocator >& x, const basic_buffer< Allocator >& y) +template < void* (*Allocator)(void*, std::size_t) > +bool operator > (const basic_buffer< Allocator >& x, + const basic_buffer< Allocator >& y) { return y < x; } @@ -546,8 +549,9 @@ bool operator > (const basic_buffer< Allocator >& x, const basic_buffer< Allocat /** * Returns !(y < x). */ -template < void* (*Allocator)(void*, size_t) > -bool operator <= (const basic_buffer< Allocator >& x, const basic_buffer< Allocator >& y) +template < void* (*Allocator)(void*, std::size_t) > +bool operator <= (const basic_buffer< Allocator >& x, + const basic_buffer< Allocator >& y) { return !(y < x); } @@ -555,8 +559,9 @@ bool operator <= (const basic_buffer< Allocator >& x, const basic_buffer< Alloca /** * Returns !(x < y). */ -template < void* (*Allocator)(void*, size_t) > -bool operator >= (const basic_buffer< Allocator >& x, const basic_buffer< Allocator >& y) +template < void* (*Allocator)(void*, std::size_t) > +bool operator >= (const basic_buffer< Allocator >& x, + const basic_buffer< Allocator >& y) { return !(x < y); } @@ -570,7 +575,7 @@ bool operator >= (const basic_buffer< Allocator >& x, const basic_buffer< Alloca * * Invalidates all references and iterators. */ -template < void* (*Allocator)(void*, size_t) > +template < void* (*Allocator)(void*, std::size_t) > void swap(basic_buffer< Allocator >& x, basic_buffer< Allocator >& y) { x.swap(y);