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.
- 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>
using namespace std;
void goodbye(const ustring& s) {
}
public:
void hello(const ustring& s) {
}
};
int main() {
using example_function =
delegate<void(
const ustring&)>;
ustring str("World");
example_function
f = {std::bind(&::object::hello, &instance, std::placeholders::_1)};
return 0;
}
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
delegate()=default
Initializes an empty delegate.
object()=default
Create a new instance of the ultimate base class object.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
|
| delegate ()=default |
| Initializes an empty delegate. More...
|
|
| delegate (const delegate &delegate) noexcept |
| Initializes a delegate that invokes the specified delegate instance. More...
|
|
template<typename 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. More...
|
|
template<typename 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. More...
|
|
void | clear () |
| Clear delegates array. More...
|
|
const std::vector< function_t > & | functions () const |
| Gets the delegates array. More...
|
|
result_t | invoke () const |
| invokes the method represented by the current delegate. More...
|
|
bool | is_empty () const noexcept |
| Return if the delegate is empty. More...
|
|
bool | operator!= (const delegate &delegate) const |
| Determines whether this instance and another specified delegateType object have the same value. More...
|
|
result_t | operator() () const |
| invokes the method represented by the current delegate. More...
|
|
delegate & | operator= (const function_t &function) noexcept |
|
bool | operator== (const delegate &delegate) const noexcept |
| Determines whether this instance and another specified delegateType object have the same value. More...
|
|
| object ()=default |
| Create a new instance of the ultimate base class object. More...
|
|
virtual bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object. More...
|
|
virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type. More...
|
|
template<typename object_t > |
std::unique_ptr< object_t > | memberwise_clone () const |
| Gets the type of the current instance. More...
|
|
virtual xtd::ustring | to_string () const noexcept |
| Returns a std::string that represents the current object. More...
|
|