Skip to content

Commit

Permalink
Add links
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed May 14, 2024
1 parent 7074894 commit cb4be5d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/documentation/Guides/xtd.core/Types overview/delegates.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ This ability to refer to a method as a parameter makes delegates ideal for defin

## Difference betwwen xtd::delegate and std::function

Unlike std::function, xtd::delegate can be chained together; for example, multiple methods can be called on a single event.
Unlike [std::function](https://en.cppreference.com/w/cpp/utility/functional/function), [xtd::delegate](https://github.com/gammasoft71/xtd/blob/master/src/xtd.core/include/xtd/delegate.h) can be chained together; for example, multiple methods can be called on a single event.

A xtd::delegate is a collection of std::function.
A [xtd::delegate](https://github.com/gammasoft71/xtd/blob/master/src/xtd.core/include/xtd/delegate.h) is a collection of [std::function](https://en.cppreference.com/w/cpp/utility/functional/function).

## Delegates Overview

Delegates have the following properties:
* Delegates are similar to C++ function pointers, but delegates like std::function are fully object-oriented, and unlike C++ pointers to member functions, delegates encapsulate both an object instance and a method.
* Delegates are similar to C++ function pointers, but delegates like [std::function](https://en.cppreference.com/w/cpp/utility/functional/function) are fully object-oriented, and unlike C++ pointers to member functions, delegates encapsulate both an object instance and a method.
* Delegates allow methods to be passed as parameters.
* Delegates can be used to define callback methods.
* Unlike std::function, delegates can be chained together; for example, multiple methods can be called on a single event.
* Unlike [std::function](https://en.cppreference.com/w/cpp/utility/functional/function), delegates can be chained together; for example, multiple methods can be called on a single event.
* Lambda expressions are a more concise way of writing inline code blocks. Lambda expressions (in certain contexts) are compiled to delegate types. For more information about lambda expressions, see [Lambda expressions](https://en.cppreference.com/w/cpp/language/lambda).

## Using Delegates
Expand Down Expand Up @@ -292,7 +292,7 @@ introduce(42, 2.7);
// This is world!
```

This functionality of lambda expression is supported by [xtd::delegate](https://github.com/gammasoft71/xtd/blob/master/src/xtd.core/include/xtd/delegate.h) but not by std::function.
This functionality of lambda expression is supported by [xtd::delegate](https://github.com/gammasoft71/xtd/blob/master/src/xtd.core/include/xtd/delegate.h) but not by [std::function](https://en.cppreference.com/w/cpp/utility/functional/function).

## See also

Expand Down

0 comments on commit cb4be5d

Please sign in to comment.