xtd 0.2.0
Loading...
Searching...
No Matches
action.cpp

Shows how to use xtd::action alias.

#include <xtd/collections/generic/list>
#include <xtd/action>
#include <xtd/console>
#include <algorithm>
using namespace xtd;
using namespace xtd::collections::generic;
auto main() -> int {
auto names = list {"Bruce", "Alfred", "Tim", "Richard"};
auto print = action<const string&> {[](const string & value) {
console::write_line(value);
}};
// Display the contents of the list using the print delegate.
std::for_each(names.begin(), names.end(), print);
// The following demonstrates the lambda of c++ to display the contents of the list to the console.
std::for_each(names.begin(), names.end(), [](const string & value) {
console::write_line(value);
});
}
// This code produces the following output :
//
// Bruce
// Alfred
// Tim
// Richard
// Bruce
// Alfred
// Tim
// Richard
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:72
delegate< void(arguments_t...)> action
Represents a xtd::delegate that has variable parameters and does not return a value.
Definition action.hpp:20
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:15
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10