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

Shows how to use xtd::delegate class.

#include <xtd/console>
#include <xtd/delegate>
using namespace xtd;
class test_delegate {
public:
test_delegate() = default;
void write(const string& str) {
console::write_line(str);
}
};
auto main() -> int {
// use delegate as std::function with std::bind
auto td = test_delegate {};
auto writer = delegate<void(const string& str)> {td, &test_delegate::write};
writer("String to write");
}
// This code produces the following output :
//
// String to write
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10