Bug 140401

Summary: Make WTF::Optional work with msvc 2013
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Web Template FrameworkAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, benjamin, cmarcelo, commit-queue, darin, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 140347    
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2015-01-13 11:45:14 PST
Make WTF::Optional work with mdvc 2013 by using std::aligned_memory instead of an unrestricted union internally. MSVC 2013 still does not support unrestricted unions.
Comment 1 Chris Dumez 2015-01-13 11:57:20 PST
Created attachment 244531 [details]
Patch
Comment 2 Anders Carlsson 2015-01-13 12:02:43 PST
Comment on attachment 244531 [details]
Patch

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

> Source/WTF/wtf/Optional.h:65
> +            new (&m_value) T(*other.asPtr());

I still think you want NotNull here.

> Source/WTF/wtf/Optional.h:72
> +            new (&m_value) T(WTF::move(*other.asPtr()));

I still think you want NotNull here.

> Source/WTF/wtf/Optional.h:78
> +        new (&m_value) T(WTF::move(value));

NotNull.

> Source/WTF/wtf/Optional.h:85
> +        new (&m_value) T(std::forward<Args>(args)...);

NotNull.

> Source/WTF/wtf/Optional.h:106
> +            new (&m_value) T(*other.asPtr());

NotNull.

> Source/WTF/wtf/Optional.h:-138
> -    template<typename U>
> -    Optional& operator=(U&& u)

What happened to this overload?

> Source/WTF/wtf/Optional.h:119
> +            new (&m_value) T(WTF::move(*other.asPtr()));

NotNull.
Comment 3 Chris Dumez 2015-01-13 12:22:51 PST
Created attachment 244535 [details]
Patch
Comment 4 Chris Dumez 2015-01-13 12:24:15 PST
Comment on attachment 244531 [details]
Patch

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

>> Source/WTF/wtf/Optional.h:65
>> +            new (&m_value) T(*other.asPtr());
> 
> I still think you want NotNull here.

Right, done.

>> Source/WTF/wtf/Optional.h:-138
>> -    Optional& operator=(U&& u)
> 
> What happened to this overload?

I had trouble getting it to build initially and forgot to add it back. It is back in.
Comment 5 WebKit Commit Bot 2015-01-13 13:21:40 PST
Comment on attachment 244535 [details]
Patch

Clearing flags on attachment: 244535

Committed r178372: <http://trac.webkit.org/changeset/178372>
Comment 6 WebKit Commit Bot 2015-01-13 13:21:46 PST
All reviewed patches have been landed.  Closing bug.