Bug 141571 - Add a move constructor and move assignment operator to Deque
Summary: Add a move constructor and move assignment operator to Deque
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-13 11:43 PST by Anders Carlsson
Modified: 2015-02-16 08:12 PST (History)
4 users (show)

See Also:


Attachments
Patch (4.78 KB, patch)
2015-02-13 11:44 PST, Anders Carlsson
kling: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.