diff options
author | 2022-11-22 10:13:38 -0800 | |
---|---|---|
committer | 2022-11-22 14:00:51 -0800 | |
commit | f28341eea6759d49ed6d9ba1d97ed1c6602fa0a4 (patch) | |
tree | 674ee5e13cedc6e356c6e400af693b27f4a61582 /include/ftl | |
parent | 686360612b52e825e516ccc706e9c7c43e316c65 (diff) |
ftl: add comparison operators to Optional
Add comparison operators and tests for Optional
Test: build
Bug: 185536303
Change-Id: Ic2002489f5fa04cbb8b4c7aba57c8213b9719944
Diffstat (limited to 'include/ftl')
-rw-r--r-- | include/ftl/optional.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/ftl/optional.h b/include/ftl/optional.h index 626507fd8f..7b02bac340 100644 --- a/include/ftl/optional.h +++ b/include/ftl/optional.h @@ -97,6 +97,16 @@ struct Optional final : std::optional<T> { } }; +template <typename T, typename U> +constexpr bool operator==(const Optional<T>& lhs, const Optional<U>& rhs) { + return static_cast<std::optional<T>>(lhs) == static_cast<std::optional<U>>(rhs); +} + +template <typename T, typename U> +constexpr bool operator!=(const Optional<T>& lhs, const Optional<U>& rhs) { + return !(lhs == rhs); +} + // Deduction guides. template <typename T> Optional(T) -> Optional<T>; |