You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a class which has a eastl::vector_multimap which is backed by a vector.
In my default move assignment operator for my class, I'm getting an error because my value types are move-only and eastl::vector is trying to copy them.
#if EASTL_MOVE_SEMANTICS_ENABLED
template <typename T, typename Allocator>
typename vector<T, Allocator>::this_type&
vector<T, Allocator>::operator=(this_type&& x)
{
if(this != &x)
{
DoClearCapacity(); // To consider: Are we really required to clear here? x is going away soon and will clear itself in its dtor.
swap(x); // member swap handles the case that x has a different allocator than our allocator by doing a copy. **** <===== THIS LINE
}
return *this;
}
#endif
and eventually the stack trace gets to the point where it tries to make a copy of a unique_ptr and fails.
Why is it doing a copy instead of a move? Does this mean I cannot put move-only types in a vector?
The text was updated successfully, but these errors were encountered:
xaxxon
changed the title
eastl::vector move assignment operator copies elements?
eastl::vector move assignment operator and move constructor makes copies of elements?
Sep 18, 2016
I have a class which has a eastl::vector_multimap which is backed by a vector.
In my default move assignment operator for my class, I'm getting an error because my value types are move-only and eastl::vector is trying to copy them.
When I dig into the code, I get:
then
and eventually the stack trace gets to the point where it tries to make a copy of a unique_ptr and fails.
Why is it doing a copy instead of a move? Does this mean I cannot put move-only types in a vector?
The text was updated successfully, but these errors were encountered: