Skip to content

Commit 1955133

Browse files
committed
Add invocable_r
1 parent 948946b commit 1955133

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

source/bounded/concepts.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ concept trivially_copy_assignable = copy_assignable<T> and std::is_trivially_cop
4848
export template<typename T>
4949
concept trivially_swappable = std::is_trivially_copyable_v<T> and std::is_trivially_copy_assignable_v<T> and std::is_trivially_destructible_v<T>;
5050

51+
export template<typename Function, typename Return, typename... Args>
52+
concept invocable_r = requires(Function function) {
53+
{ function(declval<Args>()...) } -> convertible_to<Return>;
54+
};
55+
5156
} // namespace bounded
5257

5358
static_assert(bounded::constructible_from<void, void>);
@@ -69,3 +74,11 @@ static_assert(!bounded::convertible_to<void, int>);
6974
static_assert(!bounded::convertible_to<unsigned long long *, unsigned long long>);
7075
static_assert(!bounded::convertible_to<unsigned long long, unsigned long long *>);
7176
static_assert(!bounded::convertible_to<int *, unsigned *>);
77+
78+
static_assert(bounded::invocable_r<void(*)(), void>);
79+
static_assert(!bounded::invocable_r<void(*)(int), void>);
80+
static_assert(bounded::invocable_r<void(*)(int), void, int>);
81+
static_assert(bounded::invocable_r<bool(*)(), bool>);
82+
static_assert(!bounded::invocable_r<bool(*)(int), bool>);
83+
static_assert(bounded::invocable_r<bool(*)(int), bool, int>);
84+
static_assert(bounded::invocable_r<int(*)(unsigned), bool, int>);

0 commit comments

Comments
 (0)