concepts: add initial invocable concept

This commit is contained in:
Danny Robson 2020-02-25 11:16:16 +11:00
parent 25460cc527
commit fb4e70d146

View File

@ -11,6 +11,7 @@
#include <type_traits>
#include <iterator>
#include <utility>
#include <functional>
///////////////////////////////////////////////////////////////////////////////
@ -134,6 +135,25 @@ namespace cruft::concepts {
{ 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...>>;
}