xtd 1.0.0
Loading...
Searching...
No Matches
xtd::invocable< function_t, result_t, args_t > Struct Template Reference

Definition

template<class function_t, class result_t = void, class... args_t>
struct xtd::invocable< function_t, result_t, args_t >

Represents the invocable (function, method, xtd::delegate, xtd::event, std::functional) concept.

Definition
template<class function_t, class result_t = void, class... args_t>
concept invocable = std::invocable<function_t, args_t...> && (std::is_void_v<result_t> || std::convertible_to<std::invoke_result_t<function_t, args_t...>, result_t>);
Represents the invocable (function, method, xtd::delegate, xtd::event, std::functional) concept.
Definition invocable_.hpp:47
Header
#include <xtd/invocable>
Namespace
xtd
Library
xtd.core
Examples
The following code shows how to use xtd::invocable concept
#include <xtd/xtd>
template<class value_t>
auto sort_with(const array<value_t>& items, invocable<int, value_t, value_t> auto fct) -> array<value_t> {
auto result = items;
result.sort(fct);
return result;
}
int main() {
auto items = array {8.0, 2.0, 5.0, 9.0, 4.0, 1.0, 6.0, 7.0, 10.0, 3.0};
println("items = {}", sort_with(items, [](auto a, auto b) {return a - b;}));
}
// This code produces the following output :
//
// items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
@ a
The A key.
Definition console_key.hpp:88
@ b
The B key.
Definition console_key.hpp:90
auto println(FILE *file) -> void
Writes the current line terminator to the file output stream using the specified format information.
Definition println.hpp:14

The documentation for this struct was generated from the following file: