Bug 74159 - Fix HashMap<..., OwnPtr<...> >::add compilation errors
Summary: Fix HashMap<..., OwnPtr<...> >::add compilation errors
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: Adrienne Walker
URL:
Keywords:
Depends on:
Blocks: 74154
  Show dependency treegraph
 
Reported: 2011-12-08 20:18 PST by Adrienne Walker
Modified: 2011-12-09 10:59 PST (History)
3 users (show)

See Also:


Attachments
Patch (1.36 KB, patch)
2011-12-08 20:34 PST, Adrienne Walker
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adrienne Walker 2011-12-08 20:18:13 PST
Fix HashMap<..., OwnPtr<...> >::add compilation errors
Comment 1 Adrienne Walker 2011-12-08 20:34:12 PST
Created attachment 118521 [details]
Patch
Comment 2 Adrienne Walker 2011-12-08 20:37:21 PST
When I saw Adam's fix for bug 73964, I thought I'd take advantage of using an OwnPtr as the value for a HashMap in CCLayerTilingData.  When I did this (see patch in bug 74154), I got the following compilation error:

/usr/include/c++/4.4/bits/stl_pair.h: In constructor 'std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&) [with _U1 = std::pair<int, int>, _U2 = std::nullptr_t, _T1 = std::pair<int, int>, _T2 = WTF::OwnPtr<WebCore::CCLayerTilingData::Tile>]':

/usr/include/c++/4.4/bits/stl_pair.h:101: error: no matching function for call to 'WTF::OwnPtr<WebCore::CCLayerTilingData::Tile>::OwnPtr(const std::nullptr_t&)'

So, I added this missing function to OwnPtr.
Comment 3 Darin Adler 2011-12-09 10:37:40 PST
Comment on attachment 118521 [details]
Patch

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

> Source/JavaScriptCore/wtf/OwnPtr.h:44
> +        explicit OwnPtr(const std::nullptr_t&) : m_ptr(0) { }

I see no reason for this to be explicit.

This might work for some compilers, but with others I fear it may break the build. The EWS seems to like it OK.

Since you did not include the entire error, I cannot be sure, but I suspect there may be a way to resolve this entirely in HashTraits.h. For example, it may be a simple matter of overloading some function to take a nullptr_t.

I am not going to say review+ yet because of the “explicit” issue and the fact that I’d like to see the rest of the error.
Comment 4 Darin Adler 2011-12-09 10:40:17 PST
Comment on attachment 118521 [details]
Patch

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

r=me, but please land my revised version

>> Source/JavaScriptCore/wtf/OwnPtr.h:44
>> +        explicit OwnPtr(const std::nullptr_t&) : m_ptr(0) { }
> 
> I see no reason for this to be explicit.
> 
> This might work for some compilers, but with others I fear it may break the build. The EWS seems to like it OK.
> 
> Since you did not include the entire error, I cannot be sure, but I suspect there may be a way to resolve this entirely in HashTraits.h. For example, it may be a simple matter of overloading some function to take a nullptr_t.
> 
> I am not going to say review+ yet because of the “explicit” issue and the fact that I’d like to see the rest of the error.

I changed my mind about all the rest of my comment. This is a good change.

But we should not use “explicit” here. It’s good and helpful to allow implicit conversion from nullptr_t to OwnPtr.

It should read:

    OwnPtr(std::nullptr_t) : m_ptr(0) { }

There is no reason to use const std::nullptr_t& instead of just std::nullptr_t. See PassOwnPtr, which already has this constructor.
Comment 5 Adrienne Walker 2011-12-09 10:44:53 PST
(In reply to comment #4)
>
> It should read:
> 
>     OwnPtr(std::nullptr_t) : m_ptr(0) { }
> 
> There is no reason to use const std::nullptr_t& instead of just std::nullptr_t. See PassOwnPtr, which already has this constructor.

Thanks--both of those changes make a lot of sense.  I'll land it exactly as above.
Comment 6 Adrienne Walker 2011-12-09 10:59:32 PST
Committed r102459: <http://trac.webkit.org/changeset/102459>