1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:37:46 +00:00

AK+LibWeb: Implement Variant equality operator

And make use of it for CSS StyleValues.
This commit is contained in:
kleines Filmröllchen 2023-02-07 21:10:15 +01:00 committed by Sam Atkins
parent 7dc874104b
commit d00a6ca11f
2 changed files with 12 additions and 31 deletions

View file

@ -418,6 +418,15 @@ public:
return index_of<T>() == m_index;
}
bool operator==(Variant const& other) const
{
return this->visit([&]<typename T>(T const& self) {
if (auto const* p = other.get_pointer<T>())
return static_cast<T const&>(self) == static_cast<T const&>(*p);
return false;
});
}
template<typename... Fs>
ALWAYS_INLINE decltype(auto) visit(Fs&&... functions)
{