mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-05 01:10:24 +00:00
AK: Add Variant::unsafe_get()
This performs no validation and no verifications on release. only useful when you've already verified the type by external means.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
d8ea9e67f8
commit
3e62cae2ad
Notes:
github-actions[bot]
2025-08-26 13:21:47 +00:00
Author: https://github.com/alimpfard Commit: https://github.com/LadybirdBrowser/ladybird/commit/3e62cae2ad2 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5784
16
AK/Variant.h
16
AK/Variant.h
@@ -355,6 +355,14 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& unsafe_get()
|
||||
requires(can_contain<T>())
|
||||
{
|
||||
ASSERT(has<T>());
|
||||
return *bit_cast<T*>(&m_data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& get()
|
||||
requires(can_contain<T>())
|
||||
@@ -380,6 +388,14 @@ public:
|
||||
return *bit_cast<T const*>(&m_data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T const& unsafe_get() const
|
||||
requires(can_contain<T>())
|
||||
{
|
||||
ASSERT(has<T>());
|
||||
return *bit_cast<T const*>(&m_data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] bool has() const
|
||||
requires(can_contain<T>())
|
||||
|
||||
Reference in New Issue
Block a user