mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
AK: Explictly disallow lvalue reference types within Variant
This prevents an ICE with GCC trying to declare e.g. Variant<String&>. Using a concept is a bit overkill here, but clang otherwise trips over the friendship declaration to other Variant types: template<typename... NewTs> friend struct Variant; Without using a concept, clang believes this is re-declaring the Variant type with differing requirements ("error: requires clause differs in template redeclaration").
This commit is contained in:
parent
db23e2d546
commit
d007337d97
Notes:
sideshowbarker
2024-07-18 01:43:16 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/d007337d97 Pull-request: https://github.com/SerenityOS/serenity/pull/15592 Reviewed-by: https://github.com/linusg ✅
1 changed files with 5 additions and 2 deletions
|
@ -215,7 +215,10 @@ namespace AK {
|
|||
struct Empty {
|
||||
};
|
||||
|
||||
template<typename... Ts>
|
||||
template<typename T>
|
||||
concept NotLvalueReference = !IsLvalueReference<T>;
|
||||
|
||||
template<NotLvalueReference... Ts>
|
||||
struct Variant
|
||||
: public Detail::MergeAndDeduplicatePacks<Detail::VariantConstructors<Ts, Variant<Ts...>>...> {
|
||||
private:
|
||||
|
@ -244,7 +247,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
template<typename... NewTs>
|
||||
template<NotLvalueReference... NewTs>
|
||||
friend struct Variant;
|
||||
|
||||
Variant() requires(!can_contain<Empty>()) = delete;
|
||||
|
|
Loading…
Reference in a new issue