mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +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
1 changed files with 5 additions and 2 deletions
|
@ -215,7 +215,10 @@ namespace AK {
|
||||||
struct Empty {
|
struct Empty {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename... Ts>
|
template<typename T>
|
||||||
|
concept NotLvalueReference = !IsLvalueReference<T>;
|
||||||
|
|
||||||
|
template<NotLvalueReference... Ts>
|
||||||
struct Variant
|
struct Variant
|
||||||
: public Detail::MergeAndDeduplicatePacks<Detail::VariantConstructors<Ts, Variant<Ts...>>...> {
|
: public Detail::MergeAndDeduplicatePacks<Detail::VariantConstructors<Ts, Variant<Ts...>>...> {
|
||||||
private:
|
private:
|
||||||
|
@ -244,7 +247,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... NewTs>
|
template<NotLvalueReference... NewTs>
|
||||||
friend struct Variant;
|
friend struct Variant;
|
||||||
|
|
||||||
Variant() requires(!can_contain<Empty>()) = delete;
|
Variant() requires(!can_contain<Empty>()) = delete;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue