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

This example simplifies this code by instantiating the xtd::action delegate instead of explicitly defining a new delegate and assigning a named method to it.

#include <xtd/xtd>
using display_message = delegate<void(const string&)>;
void show_windows_message(const string& message) {
forms::message_box::show(message);
}
void write_line(const string& message) {
console::write_line(message);
}
auto main() -> int {
auto message_target = display_message {};
if (environment::get_command_line_args().length() > 1)
message_target = show_windows_message;
else
message_target = write_line;
message_target("Hello, World!");
}
constexpr size_type length() const noexcept
Returns the length of the current read_only_span.
Definition read_only_span.hpp:229