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

Shows how to use xtd::collections::generic::list::for_each method.

#include <xtd/xtd>
class example {
public:
static auto main() -> void {
auto names = list<string> {};
names.add("Bruce");
names.add("Alfred");
names.add("Tim");
names.add("Richard");
names.for_each(action<const string&> {print});
names.for_each(action<const string&> {[](const string& name) {
console::write_line(name);
}});
}
private:
static void print(const string& s) {
console::write_line(s);
}
};
startup_(example::main);
// This code produces the following output :
//
// Bruce
// Alfred
// Tim
// Richard
// Bruce
// Alfred
// Tim
// Richard
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:168