WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
214224
Make hasher work with tuple-like classes
https://bugs.webkit.org/show_bug.cgi?id=214224
Summary
Make hasher work with tuple-like classes
Sam Weinig
Reported
2020-07-11 12:13:13 PDT
Make hasher work with tuple-like classes
Attachments
Patch
(11.45 KB, patch)
2020-07-11 12:32 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(11.40 KB, patch)
2020-07-11 12:35 PDT
,
Sam Weinig
darin
: review+
Details
Formatted Diff
Diff
Patch + `constexpr` => `inline constexpr` template variable fix
(11.96 KB, patch)
2020-07-12 01:32 PDT
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2020-07-11 12:32:10 PDT
Comment hidden (obsolete)
Created
attachment 404063
[details]
Patch
Sam Weinig
Comment 2
2020-07-11 12:35:38 PDT
Created
attachment 404065
[details]
Patch
Darin Adler
Comment 3
2020-07-11 13:44:08 PDT
Comment on
attachment 404065
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=404065&action=review
Thanks for finishing the job. You can tell from all the FIXME that I tried this and couldn’t figure it out. Where’s the part of this patch where you use this in Color?
> Source/WTF/ChangeLog:25 > + adhear to WebKit style as IsTypeComplete<>.
adhere
> Source/WTF/wtf/StdLibExtras.h:424 > +// Based on 'Detecting in C++ whether a type is defined, part 3: SFINAE and incomplete types' > +// <
https://devblogs.microsoft.com/oldnewthing/20190710-00/?p=102678
> > +template<typename, typename = void> constexpr bool IsTypeComplete = false; > +template<typename T> constexpr bool IsTypeComplete<T, std::void_t<decltype(sizeof(T))>> = true;
Why rename IsTypeComplete? If we’re just previewing C++20, could we use the real name and inject in the std namespace? Or maybe this is the way to go.
Sam Weinig
Comment 4
2020-07-11 15:08:16 PDT
(In reply to Darin Adler from
comment #3
)
> Comment on
attachment 404065
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=404065&action=review
> > Thanks for finishing the job. You can tell from all the FIXME that I tried > this and couldn’t figure it out. > > Where’s the part of this patch where you use this in Color?
Since I have not landed that one yet (still needs a final r+), I figured I land this first, and land the fix for WTF first.
> > > Source/WTF/ChangeLog:25 > > + adhear to WebKit style as IsTypeComplete<>. > > adhere > > > Source/WTF/wtf/StdLibExtras.h:424 > > +// Based on 'Detecting in C++ whether a type is defined, part 3: SFINAE and incomplete types' > > +// <
https://devblogs.microsoft.com/oldnewthing/20190710-00/?p=102678
> > > +template<typename, typename = void> constexpr bool IsTypeComplete = false; > > +template<typename T> constexpr bool IsTypeComplete<T, std::void_t<decltype(sizeof(T))>> = true; > > Why rename IsTypeComplete? If we’re just previewing C++20, could we use the > real name and inject in the std namespace? Or maybe this is the way to go.
I don't think it's a c++20 thing, just a useful trait that Raymond Chen blogged about. Thanks.
Sam Weinig
Comment 5
2020-07-11 15:12:46 PDT
Committed
r264270
: <
https://trac.webkit.org/changeset/264270
>
Radar WebKit Bug Importer
Comment 6
2020-07-11 15:13:15 PDT
<
rdar://problem/65410178
>
Yusuke Suzuki
Comment 7
2020-07-11 21:37:51 PDT
Re-opened since this is blocked by
bug 214228
Alexey Proskuryakov
Comment 8
2020-07-11 21:38:56 PDT
Reverting due to broken build, failure details in Slack.
Yusuke Suzuki
Comment 9
2020-07-12 01:32:40 PDT
Created
attachment 404090
[details]
Patch + `constexpr` => `inline constexpr` template variable fix
Yusuke Suzuki
Comment 10
2020-07-12 02:19:38 PDT
(In reply to Yusuke Suzuki from
comment #9
)
> Created
attachment 404090
[details]
> Patch + `constexpr` => `inline constexpr` template variable fix
Internal one is built with this fix.
Yusuke Suzuki
Comment 11
2020-07-12 02:47:12 PDT
Committed
r264277
: <
https://trac.webkit.org/changeset/264277
>
Yusuke Suzuki
Comment 12
2020-07-12 03:39:34 PDT
Comment on
attachment 404065
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=404065&action=review
I've relanded the patch with `inline constexpr` fix, and note the rationale why this is necessary here :)
> Source/WTF/wtf/Hasher.h:110 > +template<typename, typename = void> constexpr bool HasBeginFunctionMember = false; > +template<typename T> constexpr bool HasBeginFunctionMember<T, std::void_t<decltype(std::declval<T>().begin())>> = true;
We need `inline constexpr` to make this template-variable inline-variable (C++ is super complicated!)
https://stackoverflow.com/questions/14391272/does-constexpr-imply-inline
> Source/WTF/wtf/Hasher.h:129 > +template<typename T> constexpr bool HasGetFunctionMember<T, std::void_t<decltype(std::declval<T>().template get<0>())>> = true;
Ditto. Work-around with `inline constexpr`.
>> Source/WTF/wtf/StdLibExtras.h:424 >> +template<typename T> constexpr bool IsTypeComplete<T, std::void_t<decltype(sizeof(T))>> = true; > > Why rename IsTypeComplete? If we’re just previewing C++20, could we use the real name and inject in the std namespace? Or maybe this is the way to go.
Ditto :)
Darin Adler
Comment 13
2020-07-12 08:32:06 PDT
Comment on
attachment 404065
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=404065&action=review
>> Source/WTF/wtf/Hasher.h:110 >> +template<typename T> constexpr bool HasBeginFunctionMember<T, std::void_t<decltype(std::declval<T>().begin())>> = true; > > We need `inline constexpr` to make this template-variable inline-variable (C++ is super complicated!) >
https://stackoverflow.com/questions/14391272/does-constexpr-imply-inline
This is the first time I have ever heard of an inline variable!
>>> Source/WTF/wtf/StdLibExtras.h:424 >>> +template<typename T> constexpr bool IsTypeComplete<T, std::void_t<decltype(sizeof(T))>> = true; >> >> Why rename IsTypeComplete? If we’re just previewing C++20, could we use the real name and inject in the std namespace? Or maybe this is the way to go. > > Ditto :)
Sam clarified that is_type_complete is not in C++20.
Yusuke Suzuki
Comment 14
2020-07-12 15:09:31 PDT
Comment on
attachment 404065
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=404065&action=review
>>> Source/WTF/wtf/Hasher.h:110 >>> +template<typename T> constexpr bool HasBeginFunctionMember<T, std::void_t<decltype(std::declval<T>().begin())>> = true; >> >> We need `inline constexpr` to make this template-variable inline-variable (C++ is super complicated!) >>
https://stackoverflow.com/questions/14391272/does-constexpr-imply-inline
> > This is the first time I have ever heard of an inline variable!
inline variable is one of the best feature in C++17! Sometimes we, C++ developers, saw super weird linker errors about `static XXX::value` variables defined in the header because, 1. One translation unit is accessing it via reference. 2. One translation unit is building it as a constant value and do not generate a data for that. Then linker causes link failures because (1) cannot find the referenced data. Inline variable solves this problem by ensuring that this variable is not referenced like (1).
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug