AK: Add a concept for requiring that a function is fallible

This ensures that the function may be wrapped with TRY() and MUST().
This commit is contained in:
Timothy Flynn 2022-11-17 07:52:39 -05:00 committed by Linus Groh
parent 862320828f
commit 56ab529752
Notes: sideshowbarker 2024-07-17 04:23:34 +09:00

View file

@ -111,12 +111,20 @@ concept IterableContainer = requires
{ declval<T>().begin() } -> IteratorPairWith<decltype(declval<T>().end())>;
};
template<typename Func, typename... Args>
concept FallibleFunction = requires(Func&& func, Args&&... args) {
func(forward<Args>(args)...).is_error();
func(forward<Args>(args)...).release_error();
func(forward<Args>(args)...).release_value();
};
// clang-format on
}
using AK::Concepts::Arithmetic;
using AK::Concepts::ArrayLike;
using AK::Concepts::Enum;
using AK::Concepts::FallibleFunction;
using AK::Concepts::FloatingPoint;
using AK::Concepts::Fundamental;
using AK::Concepts::Integral;