allow/raw: rename base as begin

This commit is contained in:
Danny Robson 2017-08-31 13:48:33 +10:00
parent 367fc1dcb1
commit 0e97044adf
11 changed files with 32 additions and 26 deletions

View File

@ -35,8 +35,8 @@ namespace util::alloc::raw {
void deallocate (void *ptr, size_t bytes);
void deallocate (void *ptr, size_t bytes, size_t align);
void* base (void);
const void* base (void) const;
void* begin (void);
const void* begin (void) const;
size_t offset (const void*) const;
};

View File

@ -66,8 +66,8 @@ namespace util::alloc::raw {
///////////////////////////////////////////////////////////////////////
auto base (void) { return m_successor.base (); }
auto base (void) const { return m_successor.base (); }
auto begin (void) { return m_successor.begin (); }
auto begin (void) const { return m_successor.begin (); }
//---------------------------------------------------------------------

View File

@ -57,8 +57,8 @@ namespace util::alloc::raw {
auto deallocate (void *ptr, size_t bytes, size_t alignment) { return m_child->deallocate (ptr, bytes, alignment); }
//---------------------------------------------------------------------
auto base (void) { return m_child->base (); }
auto base (void) const { return m_child->base (); }
auto begin (void) { return m_child->begin (); }
auto begin (void) const { return m_child->begin (); }
auto offset (const void *ptr) const
{ return m_child->offset (ptr); }
@ -93,8 +93,8 @@ namespace util::alloc::raw {
virtual void deallocate (void *ptr, size_t bytes) = 0;
virtual void deallocate (void *ptr, size_t bytes, size_t alignment) = 0;
virtual void* base (void) = 0;
virtual const void* base (void) const = 0;
virtual void* begin (void) = 0;
virtual const void* begin (void) const = 0;
virtual size_t offset (const void*) const = 0;
virtual void reset (void) = 0;
@ -133,12 +133,12 @@ namespace util::alloc::raw {
{ m_target.deallocate (ptr, bytes, alignment); }
const void*
base (void) const override
{ return m_target.base (); }
begin (void) const override
{ return m_target.begin (); }
void*
base (void) override
{ return m_target.base (); }
begin (void) override
{ return m_target.begin (); }
size_t
offset (const void *ptr) const override

View File

@ -77,7 +77,7 @@ linear::deallocate (void *ptr, size_t bytes, size_t alignment)
//-----------------------------------------------------------------------------
void*
linear::base (void)
linear::begin (void)
{
return m_begin;
}
@ -85,7 +85,7 @@ linear::base (void)
//-----------------------------------------------------------------------------
const void*
linear::base (void) const
linear::begin (void) const
{
return m_begin;
}

View File

@ -43,8 +43,14 @@ namespace util::alloc::raw {
void deallocate (void *ptr, size_t bytes);
void deallocate (void *ptr, size_t bytes, size_t alignment);
void* base (void);
const void* base (void) const;
void* begin (void);
void* end (void);
void* cursor (void);
const void* begin (void) const;
const void* end (void) const;
const void* cursor (void) const;
size_t offset (const void*) const;
void reset (void);

View File

@ -68,7 +68,7 @@ null::deallocate (void *ptr, size_t bytes, size_t align)
///////////////////////////////////////////////////////////////////////////////
void*
null::base (void)
null::begin (void)
{
return nullptr;
}
@ -76,7 +76,7 @@ null::base (void)
//-----------------------------------------------------------------------------
const void*
null::base (void) const
null::begin (void) const
{
return nullptr;
}

View File

@ -35,8 +35,8 @@ namespace util::alloc::raw {
void deallocate (void *ptr, size_t bytes);
void deallocate (void *ptr, size_t bytes, size_t align);
void* base (void);
const void* base (void) const;
void* begin (void);
const void* begin (void) const;
size_t offset (const void*) const;
void reset (void);

View File

@ -113,7 +113,7 @@ stack::deallocate (void *_ptr, size_t bytes, size_t alignment)
//-----------------------------------------------------------------------------
void*
stack::base (void)
stack::begin (void)
{
return m_begin;
}
@ -121,7 +121,7 @@ stack::base (void)
//-----------------------------------------------------------------------------
const void*
stack::base (void) const
stack::begin (void) const
{
return m_begin;
}

View File

@ -38,8 +38,8 @@ namespace util::alloc::raw {
void deallocate (void *ptr, size_t bytes);
void deallocate (void *ptr, size_t bytes, size_t alignment);
void* base (void);
const void* base (void) const;
void* begin (void);
const void* begin (void) const;
size_t offset (const void*) const;
void reset (void);

View File

@ -13,7 +13,7 @@ main (void)
alignas (std::max_align_t) char memory[BUFFER_SIZE];
util::alloc::raw::linear store (std::begin (memory), std::end (memory));
tap.expect_eq (store.base (), std::begin (memory), "base pointers match");
tap.expect_eq (store.begin (), std::begin (memory), "base pointers match");
tap.expect_eq (store.offset (std::begin (memory)), 0u, "base offset is 0");
tap.expect_eq (store.capacity (), BUFFER_SIZE, "bytes capacity matches");

View File

@ -34,7 +34,7 @@ main (void)
util::alloc::raw::stack store (memory, memory + BUFFER_AVAILABLE);
tap.expect_eq (store.base (), std::begin (memory), "base pointers match");
tap.expect_eq (store.begin (), std::begin (memory), "base pointers match");
tap.expect_eq (store.offset (std::begin (memory)), 0u, "base offset is 0");
tap.expect_eq (store.capacity (), BUFFER_AVAILABLE, "bytes capacity matches");