template<typename result_t>
class xtd::delegate< result_t()>
Represents a delegate, which is a data structure that refers to a static method or to a class instance && an instance method of that class.
- Header
-
- Namespace
- xtd
- Library
- xtd.core
- Examples
- The following example shows how to define a delegate named my Method delegate. Instances of this delegate are created for an instance method && a static method of the nested mySampleClass class. The delegate for the instance method requires an instance of mySampleClass. The mySampleClass instance is saved in a variable named mySC.
#include <xtd/xtd>
auto goodbye(const string& s) -> void {
}
public:
auto hello(const string& s) -> void {
}
};
auto main() -> int {
using example_function = delegate<void(const string&)>;
auto instance = ::object {};
auto str = string {"World"};
auto f = example_function {instance, &::object::hello};
return 0;
}
static auto write_line() -> void
Writes the current line terminator to the standard output stream using the specified format informati...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
@ f
The F key.
Definition console_key.hpp:98
|
| | delegate ()=default |
| | Initializes an empty delegate.
|
| | delegate (const function_t &function) noexcept |
| | Initializes a delegate that invokes the specified instance method.
|
| template<class object1_t, typename object2_t> |
| | delegate (const object1_t &object, result_t(object2_t::*method)() const) noexcept |
| | Initializes a delegate that invokes the specified instance method on the specified class instance.
|
| template<class object1_t, typename object2_t> |
| | delegate (const object1_t &object, result_t(object2_t::*method)()) noexcept |
| | Initializes a delegate that invokes the specified instance method on the specified class instance.
|
|
| void | clear () |
| | Clear delegates array.
|
| async_result | begin_invoke () |
| | Executes the method represented by the current delegate asynchronously on the thread that the control's underlying handle was created on.
|
| async_result | begin_invoke (xtd::async_callback async_callback) |
| | Executes the method represented by the current delegate asynchronously on the thread that the control's underlying handle was created on.
|
| async_result | begin_invoke (xtd::async_callback async_callback, const xtd::any_object &async_state) |
| | Executes the method represented by the current delegate asynchronously on the thread that the control's underlying handle was created on.
|
| result_t | end_invoke (async_result async) |
| | Retrieves the return value of the asynchronous operation represented by the async_result_invoke passed.
|
| result_t | invoke () const |
| | invokes the method represented by the current delegate.
|
| bool | equals (const object &obj) const noexcept override |
| | Determines whether this instance and another specified delegateType object have the same value.
|
| bool | equals (const delegate &other) const noexcept override |
| | Determines whether this instance and another specified delegateType object have the same value.
|
|
| | object ()=default |
| | Create a new instance of the ultimate base class object.
|
| virtual xtd::size | get_hash_code () const noexcept |
| | Serves as a hash function for a particular type.
|
| virtual type_object | get_type () const noexcept |
| | Gets the type of the current instance.
|
| template<typename object_t> |
| xtd::unique_ptr_object< object_t > | memberwise_clone () const |
| | Creates a shallow copy of the current object.
|
| virtual xtd::string | to_string () const |
| | Returns a xtd::string that represents the current object.
|
| virtual bool | equals (const delegate< result_t() > &) const noexcept=0 |
| | Indicates whether the current object is equal to another object of the same type.
|
| template<typename object_a_t, typename object_b_t> |
| static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| | Determines whether the specified object instances are considered equal.
|
| template<typename object_a_t, typename object_b_t> |
| static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| | Determines whether the specified object instances are the same instance.
|