[Webkit-unassigned] [Bug 234683] Enhance Vector::map to allow specifying what kind of Vector to return (e.g. inline capacity, overflow, etc.)

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Dec 25 18:46:17 PST 2021


--- Comment #1 from Sam Weinig <sam at webkit.org> ---
This is a bit tricky to tack onto the existing map due to the order of template arguments:

    template<typename MapFunction, typename R = typename std::invoke_result<MapFunction, const T&>::type> Vector<R> map(MapFunction) const;

The naive approach, to make R an overridable parameter like the following:

    template<typename MapFunction, typename R = Vector<typename std::invoke_result<MapFunction, const T&>::type>> R map(MapFunction) const;

has the problem that now, to specify the Vector type, you also need to specify the MapFunction type, which can be hard / impossible when used with lambdas.

My current idea is to use overloading + SFINAE to have another version that looks like:

    template<typename R, typename MapFunction, typename SOME_SFINAE_TEST_HERE> R map(MapFunction) const;

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211226/e8ed5d56/attachment.htm>

More information about the webkit-unassigned mailing list