Bug 211698 - Use alias template to define `match_constness` in Wtf/wtp/TypeCasts.h
Summary: Use alias template to define `match_constness` in Wtf/wtp/TypeCasts.h
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 211714
  Show dependency treegraph
 
Reported: 2020-05-10 09:51 PDT by Tetsuharu Ohzeki [UTC+9]
Modified: 2020-05-11 01:15 PDT (History)
7 users (show)

See Also:


Attachments
Patch (2.62 KB, patch)
2020-05-10 10:27 PDT, Tetsuharu Ohzeki [UTC+9]
no flags Details | Formatted Diff | Diff
Patch (2.63 KB, patch)
2020-05-10 18:47 PDT, Tetsuharu Ohzeki [UTC+9]
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tetsuharu Ohzeki [UTC+9] 2020-05-10 09:51:38 PDT
This is pretty trivial change....
May I change this?
Comment 1 Tetsuharu Ohzeki [UTC+9] 2020-05-10 10:27:40 PDT
Created attachment 398977 [details]
Patch
Comment 2 Yusuke Suzuki 2020-05-10 14:49:08 PDT
Comment on attachment 398977 [details]
Patch

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

r=me with nit.

> Source/WTF/wtf/TypeCasts.h:71
> +using match_constness =
> +    typename std::conditional<std::is_const<Reference>::value, typename std::add_const<T>::type, typename std::remove_const<T>::type>::type;

`match_correctness` looks like not following to the WebKit's naming convention. Based on https://bugs.webkit.org/show_bug.cgi?id=140905#c4, I guess that this is intentionally using C++ STL's naming convention here.
Then, can you change this to `match_constness_t`? When using alias template and generating type without using `::type`, C++ STL uses `_t` suffix. e.g. https://en.cppreference.com/w/cpp/types/make_signed
Comment 3 Tetsuharu Ohzeki [UTC+9] 2020-05-10 18:47:07 PDT
Created attachment 398990 [details]
Patch
Comment 4 Tetsuharu Ohzeki [UTC+9] 2020-05-10 18:55:06 PDT
Comment on attachment 398990 [details]
Patch

Yusuke, could you review this patch again?
Comment 5 EWS 2020-05-10 21:46:17 PDT
Committed r261465: <https://trac.webkit.org/changeset/261465>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 398990 [details].
Comment 6 Radar WebKit Bug Importer 2020-05-10 21:47:16 PDT
<rdar://problem/63075552>
Comment 7 Darin Adler 2020-05-10 23:18:09 PDT
Comment on attachment 398990 [details]
Patch

Surprised that the standard library doesn’t have something like this.
Comment 8 Darin Adler 2020-05-10 23:40:23 PDT
Comment on attachment 398990 [details]
Patch

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

> Source/WTF/wtf/TypeCasts.h:71
> +    typename std::conditional<std::is_const<Reference>::value, typename std::add_const<T>::type, typename std::remove_const<T>::type>::type;

As long as we are modernizing, should use conditional_t, is_const_v, add_const_t, and remove_const_t.