Shows how to use xtd::delegate class.
#define TRACE
#include <xtd/console>
#include <xtd/cdebug>
#include <xtd/ctrace>
#include <xtd/delegate>
#include <xtd/environment>
using writer = delegate<void(const string& str)>;
void write_debug(const string& str) {
}
class tracer {
public:
void write_trace(const string& str) {
}
void write_trace2(const string& str) {
ctrace <<
"2 " << str << environment::new_line;
}
};
auto main() -> int {
write += [](
const string & str) {
};
};
write += {tracer(), &tracer::write_trace};
write += {
t, &tracer::write_trace2};
write -= {
t, &tracer::write_trace2};
struct writer {
writer() = default;
void operator()(const string& str) {
console::write_line(str);
}
};
}
static std::ostream error
Gets the error output stream. A std::basic_ostream<char_t> that represents the error output stream.
Definition console.hpp:42
static std::ostream out
Gets the standard output stream. A std::basic_ostream<char_t> that represents the standard output str...
Definition console.hpp:52
static xtd::string new_line() noexcept
Gets the newline string defined for this environment.
std::ostream ctrace(nullptr)
Provides an std::ostream for xtd::diagnostics::trace.
@ write
Write access to the file. Data can be written to the file. Combine with Read for read/write access.
Definition file_access.hpp:19
@ t
The T key.
Definition console_key.hpp:126
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8