mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09: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
Notes:
sideshowbarker
2024-07-17 04:23:34 +09:00
Author: https://github.com/trflynn89
Commit: 56ab529752
Pull-request: https://github.com/SerenityOS/serenity/pull/16099
Reviewed-by: https://github.com/linusg
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