forked from OctaForge/libostd
follow allocator propagation rules
parent
e0a498806a
commit
4b0add9020
|
@ -800,7 +800,7 @@ namespace detail {
|
|||
} /* namespace detail */
|
||||
|
||||
template<typename A>
|
||||
using PropagateOnContainerCopyAssignment
|
||||
using AllocatorPropagateOnContainerCopyAssignment
|
||||
= typename octa::detail::PropagateOnContainerCopyAssignmentBase<A>::Type;
|
||||
|
||||
/* allocator propagate on container move assignment */
|
||||
|
@ -827,7 +827,7 @@ namespace detail {
|
|||
} /* namespace detail */
|
||||
|
||||
template<typename A>
|
||||
using PropagateOnContainerMoveAssignment
|
||||
using AllocatorPropagateOnContainerMoveAssignment
|
||||
= typename octa::detail::PropagateOnContainerMoveAssignmentBase<A>::Type;
|
||||
|
||||
/* allocator propagate on container swap */
|
||||
|
@ -853,7 +853,7 @@ namespace detail {
|
|||
} /* namespace detail */
|
||||
|
||||
template<typename A>
|
||||
using PropagateOnContainerSwap
|
||||
using AllocatorPropagateOnContainerSwap
|
||||
= typename octa::detail::PropagateOnContainerSwapBase<A>::Type;
|
||||
|
||||
/* allocator is always equal */
|
||||
|
@ -878,7 +878,7 @@ namespace detail {
|
|||
} /* namespace detail */
|
||||
|
||||
template<typename A>
|
||||
using IsAlwaysEqual = typename octa::detail::IsAlwaysEqualBase<A>::Type;
|
||||
using AllocatorIsAlwaysEqual = typename octa::detail::IsAlwaysEqualBase<A>::Type;
|
||||
|
||||
/* allocator allocate */
|
||||
|
||||
|
|
|
@ -192,6 +192,11 @@ public:
|
|||
Vector &operator=(const Vector &v) {
|
||||
if (this == &v) return *this;
|
||||
clear();
|
||||
if (octa::AllocatorPropagateOnContainerCopyAssignment<A>::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<A>::value)
|
||||
p_buf.second() = v.p_buf.second();
|
||||
p_len = v.p_len;
|
||||
p_cap = v.p_cap;
|
||||
p_buf.~VecPair();
|
||||
|
|
Loading…
Reference in New Issue