winrt::delegate struct template (C++/WinRT)
A type that you can use to declare a custom delegate type for your own events. delegate supports any number of parameters, and they are not limited to Windows Runtime types.
The delegate type has no ABI (it has no interface for use across application binaries), so its use case is when you're both authoring and consuming an event within the same project. For more details of that scenario, see Parameterized delegates, simple signals, and callbacks within a project.
For more info about handling events, and code examples, see Handle events by using delegates in C++/WinRT.
template <typename... T>
struct delegate : Windows::Foundation::IUnknown
typename... T
A variadic template parameter pack containing the types of the parameters that the delegate is passed when it's called.
Minimum supported SDK: Windows SDK version 10.0.17134.0 (Windows 10, version 1803)
Namespace: winrt
Header: %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\base.h (included by default)
Constructor | Description |
---|---|
delegate::delegate constructor | Initializes a new instance of the delegate struct from the input data. |
Operator | Description |
---|---|
delegate::operator() (function call operator) | Invokes the delegate represented by the delegate object with the provided arguments. |
Initializes a new instance of the delegate struct from the input data.
delegate(std::nullptr_t = nullptr) noexcept;
template <typename L>
delegate(L lHandler);
template <typename F>
delegate(F* fHandler);
template <typename O, typename M>
delegate(O* object, M method);
typename L
A lambda function type.
typename F
A free function type.
typename O
An object type.
typename M
A pointer-to-member-function type.
lHandler
A lambda function, which will handle the event.
fHandler
A pointer-to-free-function, which will handle the event.
object
A pointer to an object, one of whose member functions will handle the event.
method
A pointer-to-member-function, which will handle the event.
Invokes the delegate represented by the delegate object with the provided arguments.
void operator()(T const&... args) const