Skip to content

Commit

Permalink
Simplified _memOwner by base alias
Browse files Browse the repository at this point in the history
  • Loading branch information
OleErikPeistorpet committed Jun 3, 2024
1 parent 5e5abc5 commit c5955db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions dynarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,18 @@ class dynarray

struct _memOwner : public _internBase, public _usedAlloc_7KQw
{
using ::oel::_detail::DynarrBase<value_type *>::data; // owner
using ::oel::_detail::DynarrBase<value_type *>::end;
using ::oel::_detail::DynarrBase<value_type *>::reservEnd;
using B = ::oel::_detail::DynarrBase<value_type *>;

using B::data; // owner
using B::end;
using B::reservEnd;

constexpr _memOwner(_argAlloc_7KQw & a) noexcept
: ::oel::_detail::DynarrBase<value_type *>{}, _usedAlloc_7KQw{std::move(a)} {
: B{}, _usedAlloc_7KQw{std::move(a)} {
}

constexpr _memOwner(_memOwner && other) noexcept
: ::oel::_detail::DynarrBase<value_type *>{other}, _usedAlloc_7KQw{std::move(other)}
: B{other}, _usedAlloc_7KQw{std::move(other)}
{
other.reservEnd = other.end = other.data = nullptr;
}
Expand All @@ -306,8 +308,8 @@ class dynarray
{
if (data)
{
::oel::_detail::DebugAllocateWrapper<_usedAlloc_7KQw, value_type *>
::dealloc(*this, data, static_cast<size_t>(reservEnd - data));
auto cap = static_cast<size_t>(reservEnd - data);
::oel::_detail::DebugAllocateWrapper<_usedAlloc_7KQw, value_type *>::dealloc(*this, data, cap);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion unit_test/test_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ struct TrackingAllocator : TrackingAllocatorBase<T>
}

// Testing collision with internal names in dynarray
using allocator_type = TrackingAllocatorBase<T>;
using allocator_type = TrackingAllocatorBase<char>;
using Alloc = void;
struct oel {};
struct _detail {};
Expand Down

0 comments on commit c5955db

Please sign in to comment.