concepts: add initial invocable concept
This commit is contained in:
parent
25460cc527
commit
fb4e70d146
20
concepts.hpp
20
concepts.hpp
@ -11,6 +11,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -134,6 +135,25 @@ namespace cruft::concepts {
|
|||||||
{ b == a } -> boolean;
|
{ b == a } -> boolean;
|
||||||
{ b != a } -> boolean;
|
{ b != a } -> boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename FunctionT, typename ...ArgsT>
|
||||||
|
concept invocable =
|
||||||
|
requires (FunctionT &&function, ArgsT &&...args)
|
||||||
|
{
|
||||||
|
std::invoke (
|
||||||
|
std::forward<FunctionT> (function),
|
||||||
|
std::forward<ArgsT> (args)...
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename FunctionT, typename ...ArgsT>
|
||||||
|
concept regular_invocable = invocable<FunctionT, ArgsT...>;
|
||||||
|
|
||||||
|
template <typename FunctionT, typename ...ArgsT>
|
||||||
|
concept predicate =
|
||||||
|
regular_invocable<FunctionT, ArgsT...> &&
|
||||||
|
boolean<std::invoke_result_t<FunctionT, ArgsT...>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user