diff --git a/octa/memory.h b/octa/memory.h index 2a4a50f..db23892 100644 --- a/octa/memory.h +++ b/octa/memory.h @@ -800,7 +800,7 @@ namespace detail { } /* namespace detail */ template -using PropagateOnContainerCopyAssignment +using AllocatorPropagateOnContainerCopyAssignment = typename octa::detail::PropagateOnContainerCopyAssignmentBase::Type; /* allocator propagate on container move assignment */ @@ -827,7 +827,7 @@ namespace detail { } /* namespace detail */ template -using PropagateOnContainerMoveAssignment +using AllocatorPropagateOnContainerMoveAssignment = typename octa::detail::PropagateOnContainerMoveAssignmentBase::Type; /* allocator propagate on container swap */ @@ -853,7 +853,7 @@ namespace detail { } /* namespace detail */ template -using PropagateOnContainerSwap +using AllocatorPropagateOnContainerSwap = typename octa::detail::PropagateOnContainerSwapBase::Type; /* allocator is always equal */ @@ -878,7 +878,7 @@ namespace detail { } /* namespace detail */ template -using IsAlwaysEqual = typename octa::detail::IsAlwaysEqualBase::Type; +using AllocatorIsAlwaysEqual = typename octa::detail::IsAlwaysEqualBase::Type; /* allocator allocate */ diff --git a/octa/vector.h b/octa/vector.h index 5ce6e22..7169699 100644 --- a/octa/vector.h +++ b/octa/vector.h @@ -192,6 +192,11 @@ public: Vector &operator=(const Vector &v) { if (this == &v) return *this; clear(); + if (octa::AllocatorPropagateOnContainerCopyAssignment::value) { + octa::allocator_deallocate(p_buf.second(), p_buf.first(), p_cap); + p_cap = 0; + p_buf.second() = v.p_buf.second(); + } reserve(v.p_cap); p_len = v.p_len; copy_contents(v); @@ -201,6 +206,8 @@ public: Vector &operator=(Vector &&v) { clear(); octa::allocator_deallocate(p_buf.second(), p_buf.first(), p_cap); + if (octa::AllocatorPropagateOnContainerMoveAssignment::value) + p_buf.second() = v.p_buf.second(); p_len = v.p_len; p_cap = v.p_cap; p_buf.~VecPair();