summaryrefslogtreecommitdiff
path: root/Tests/AK/TestVariant.cpp
AgeCommit message (Collapse)Author
2022-01-14AK: Make Variant::visit() prefer overloads accepting T const& over T&Ali Mohammad Pur
This makes the following code behave as expected: Variant<int, String> x { some_string() }; x.visit( [](String const&) {}, // Expectation is for this to be called [](auto&) {});
2022-01-14AK+Everywhere: Make Variant::visit() respect the Variant's constnessAli Mohammad Pur
...and fix all the instances of visit() taking non-const arguments.
2021-09-21AK: Introduce ability to default-initialize a VariantBen Wiederhake
I noticed that Variant<Empty, …> is a somewhat common pattern while working on #10080, and this will simplify a few use-cases. :^)
2021-07-04AK: Destroy original value when assigning to VariantDaniel Bertalan
2021-06-26AK: Undo bogus Variant::downcast() renameAndreas Kling
I accidentally renamed these to verify_cast() when doing the global AK::downcast() rename.
2021-06-24AK: Rename downcast<T> => verify_cast<T>Andreas Kling
This makes it much clearer what this cast actually does: it will VERIFY that the thing we're casting is a T (using is<T>()).
2021-06-24Everywhere: Use nothrow new with `adopt_{ref,own}_if_nonnull`Daniel Bertalan
This commit converts naked `new`s to `AK::try_make` and `AK::try_create` wherever possible. If the called constructor is private, this can not be done, so we instead now use the standard-defined and compiler-agnostic `new (nothrow)`.
2021-05-22AK: Fix Variant construction from lvalue referencesAli Mohammad Pur
Fixes #7371 and appends its test cases.
2021-05-19AK: Allow AK::Variant::visit to return a valueTimothy Flynn
This changes Variant::visit() to forward the value returned by the selected visitor invocation. By perfectly forwarding the returned value, this allows for the visitor to return by value or reference. Note that all provided visitors must return the same type - the compiler will otherwise fail with the message: "inconsistent deduction for auto return type".
2021-05-11AK/Variant: Deduplicate the contained typesAli Mohammad Pur
This allows the construction of `Variant<int, int, int>`. While this might not seem useful, it is very useful for making variants that contain a series of member function pointers, which I plan to use in LibGL for glGenLists() and co.
2021-05-06Tests: Move AK tests to Tests/AKBrian Gianforcaro