Represents a pointer to a function, method or a function object. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.
More...
Inherits System::Details::DelegateHoldingVariables.
|
| Delegate ()=default |
| Default constructor. Constructs the delegate object that does not point to anything. More...
|
|
| Delegate (const Delegate &)=default |
|
Delegate & | operator= (const Delegate &)=default |
|
| Delegate (Delegate &&o) noexcept |
| Moving copy constructor. Takes the ownership of an entity pointed to by the specified delegate. More...
|
|
Delegate & | operator= (Delegate &&o) noexcept |
| Moving assignment operator. Takes the ownership of an entity pointed to by the specified delegate. More...
|
|
template<class T > |
| Delegate (T function, typename std::enable_if<!std::is_bind_expression< T >::value &&std::is_pointer< T >::value &&std::is_function< typename std::remove_pointer< T >::type >::value >::type *=0) |
| Constructor. Constructs a delegate object from the specified pointer to free function or static method. More...
|
|
template<class T > |
| Delegate (T function, typename std::enable_if< std::is_bind_expression< T >::value >::type *=0) |
| Constructor. Constructs a delegate from the specified pointer to the function object generated by std::bind(). More...
|
|
template<class T > |
| Delegate (int functor_tag, T &functor) |
| Constructor. Constructs a delegate from the specified function object. More...
|
|
template<class T > |
| Delegate (long functor_tag, T &&functor) |
| Moving constructor. Constructs a delegate from the specified function object. More...
|
|
template<class MemberType , class ClassType > |
| Delegate (MemberType ClassType::*member, ClassType *obj) |
| Constructor. Constructs a delegate that points to the specified non-static method of the specified object. More...
|
|
template<class MemberType , class MemberClass , class ClassType > |
| Delegate (MemberType MemberClass::*member, const SharedPtr< ClassType > &obj) |
| Constructor. Constructs a delegate that points to the specified non-static method of the specified object. More...
|
|
template<class R , class... Args> |
| Delegate (std::function< R(Args...)> f) |
| Constructs a delegate object that points to an std::function function object. More...
|
|
ReturnType | operator() (ArgumentTypes... args) const |
| Invokes a function, method or a function object that is pointed to by current delegate object. More...
|
|
bool | operator== (const Delegate &f) const |
| Compares two delegate objects to check if they point to the same entity. More...
|
|
bool | Empty () const |
| Determines if the current delegate object is empty, e.g. does not point to any entity. More...
|
|
template<class ReturnType, class... ArgumentTypes>
class System::Delegate< ReturnType(ArgumentTypes...)>
Represents a pointer to a function, method or a function object. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.
#include "system/delegate.h"
#include <iostream>
using Message = System::Delegate<void()>;
void PrintMessage()
{
std::cout << "Hello, world!" << std::endl;
}
int main()
{
Message mes = Message(&PrintMessage);
mes();
return 0;
}
- Template Parameters
-
ReturnType | The return type of a function, method or a function object pointer to which is represented by the class |
ArgumentTypes | The argument list of a function, method or a function object pointer to which is represented by the class |
template<class ReturnType , class... ArgumentTypes>
template<class MemberType , class ClassType >
System::Delegate< ReturnType(ArgumentTypes...)>::Delegate |
( |
MemberType ClassType::* |
member, |
|
|
ClassType * |
obj |
|
) |
| |
|
inline |
Constructor. Constructs a delegate that points to the specified non-static method of the specified object.
- Parameters
-
member | A pointer to the non-static method that the newly created delegate will point to |
obj | A pointer to an object member method of which will be pointed to by the newly created delegate |
- Template Parameters
-
MemberType | The type of the non-static method that the constructor accepts as an argument |
ClassType | The type of the object accepted by the constructor as an argument |
template<class ReturnType , class... ArgumentTypes>
template<class MemberType , class MemberClass , class ClassType >
System::Delegate< ReturnType(ArgumentTypes...)>::Delegate |
( |
MemberType MemberClass::* |
member, |
|
|
const SharedPtr< ClassType > & |
obj |
|
) |
| |
|
inline |
Constructor. Constructs a delegate that points to the specified non-static method of the specified object.
- Parameters
-
member | A pointer to the non-static method that the newly created delegate will point to |
obj | A shard pointer to an object member method of which will be pointed to by the newly created delegate |
- Template Parameters
-
MemberType | The type of the non-static method that the constructor accepts as an argument |
ClassType | The type of the object accepted by the constructor as an argument |