Allow WTF::map to use any class that is iterable and has a size getter
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Sep 2017 00:57:40 +0000 (00:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Sep 2017 00:57:40 +0000 (00:57 +0000)
commit69ac05c0f18d6912f4d5cc68324912242b3c285f
treefecf37f08470ec0595f70c9965dd047a4e4abc73
parentf5162a96aa76b2a81b8e88ba0f53ef8a940a4905
Allow WTF::map to use any class that is iterable and has a size getter
https://bugs.webkit.org/show_bug.cgi?id=177026

Patch by Youenn Fablet <youenn@apple.com> on 2017-09-19
Reviewed by Darin Adler.

Source/WebCore:

No change of behavior.
Using WTF::map to go from maps to vectors.

* loader/appcache/ApplicationCacheHost.cpp:
(WebCore::ApplicationCacheHost::resourceList):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchAllPendingUnloadEvents):

Source/WTF:

Computing the Item type given to the lambda using the iterator instead of ValueType which is specific to Vector.
Adding the possibility to pass a non const container reference and a lambda taking non const references as well.

* wtf/Vector.h:
(WTF::MapFunctionInspector::acceptsReference):
(WTF::Mapper::map):
(WTF::map):

Tools:

* TestWebKitAPI/Tests/WTF/Vector.cpp:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/Vector.h
Source/WebCore/ChangeLog
Source/WebCore/loader/appcache/ApplicationCacheHost.cpp
Source/WebCore/page/DOMWindow.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/Vector.cpp