Bug 141571

Summary: Add a move constructor and move assignment operator to Deque
Product: WebKit Reporter: Anders Carlsson <andersca>
Component: New BugsAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cmarcelo, commit-queue, darin
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch kling: review+

Description Anders Carlsson 2015-02-13 11:43:03 PST
Add a move constructor and move assignment operator to Deque
Comment 1 Anders Carlsson 2015-02-13 11:44:00 PST
Created attachment 246539 [details]
Patch
Comment 2 Anders Carlsson 2015-02-13 11:53:01 PST
Committed r180066: <http://trac.webkit.org/changeset/180066>
Comment 3 Darin Adler 2015-02-13 19:10:09 PST
Comment on attachment 246539 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=246539&action=review

> Source/WTF/wtf/Deque.h:327
>  template<typename T, size_t inlineCapacity>
> +inline auto Deque<T, inlineCapacity>::operator=(Deque&& other) -> Deque&
> +{
> +    swap(other);
> +    return *this;
> +}

This isn’t right. We need to clear other after swapping, I think.
Comment 4 Darin Adler 2015-02-13 19:10:37 PST
Comment on attachment 246539 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=246539&action=review

> Tools/TestWebKitAPI/Tests/WTF/Deque.cpp:182
> +    EXPECT_EQ(10u, deque2.size());

That doesn’t seem right. deque2’s size should be zero.
Comment 5 Anders Carlsson 2015-02-16 08:12:54 PST
(In reply to comment #3)
> Comment on attachment 246539 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=246539&action=review
> 
> > Source/WTF/wtf/Deque.h:327
> >  template<typename T, size_t inlineCapacity>
> > +inline auto Deque<T, inlineCapacity>::operator=(Deque&& other) -> Deque&
> > +{
> > +    swap(other);
> > +    return *this;
> > +}
> 
> This isn’t right. We need to clear other after swapping, I think.

Move constructors don't have to clear out the original; they only need to leave the moved-from object in a valid (but indeterminate) state.