mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
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:
parent
862320828f
commit
56ab529752
1 changed files with 8 additions and 0 deletions
|
@ -111,12 +111,20 @@ concept IterableContainer = requires
|
||||||
{ declval<T>().begin() } -> IteratorPairWith<decltype(declval<T>().end())>;
|
{ 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
|
// clang-format on
|
||||||
}
|
}
|
||||||
|
|
||||||
using AK::Concepts::Arithmetic;
|
using AK::Concepts::Arithmetic;
|
||||||
using AK::Concepts::ArrayLike;
|
using AK::Concepts::ArrayLike;
|
||||||
using AK::Concepts::Enum;
|
using AK::Concepts::Enum;
|
||||||
|
using AK::Concepts::FallibleFunction;
|
||||||
using AK::Concepts::FloatingPoint;
|
using AK::Concepts::FloatingPoint;
|
||||||
using AK::Concepts::Fundamental;
|
using AK::Concepts::Fundamental;
|
||||||
using AK::Concepts::Integral;
|
using AK::Concepts::Integral;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue