# AbstractDelegate

<a id="abstractdelegate"></a>

# AbstractDelegate

```cpp
#include <icy/delegate.h>

template<typename RT, typename... Args>
struct AbstractDelegate
```

[Defined in src/base/include/icy/delegate.h:29](https://github.com/auscaster/icey/blob/main/src/base/include/icy/delegate.h#L29)

Abstract delegate interface.

The `Delegate` class contains a pointer to a function. This wrapper class is used instead of `std::function` since it is interchangable with fast delegates and also provides an equality operator for comparing the underlying function where supported.

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`~AbstractDelegate`](#abstractdelegate-1) `virtual` `inline` |  |
| `RT` | [`operator()`](#operator-1) `virtual` `const` | Invokes the underlying callable with the supplied arguments. |
| `bool` | [`operator==`](#operator-2) `virtual` `const` | Compares two delegates for equality (same target function and instance). |

---

<a id="abstractdelegate-1"></a>

### ~AbstractDelegate

`virtual` `inline`

```cpp
virtual inline ~AbstractDelegate()
```

[Defined in src/base/include/icy/delegate.h:31](https://github.com/auscaster/icey/blob/main/src/base/include/icy/delegate.h#L31)

---

<a id="operator-1"></a>

### operator()

`virtual` `const`

```cpp
virtual RT operator()(Args... args) const
```

[Defined in src/base/include/icy/delegate.h:36](https://github.com/auscaster/icey/blob/main/src/base/include/icy/delegate.h#L36)

Invokes the underlying callable with the supplied arguments. 
#### Returns
Result of the wrapped function call.

#### Reimplemented by

- [`FunctionDelegate::operator()`](https://auscaster.com/icey/docs/api-reference/icy-FunctionDelegate.md#operator-28)
- [`ClassDelegate::operator()`](https://auscaster.com/icey/docs/api-reference/icy-ClassDelegate.md#operator-7)
- [`ConstClassDelegate::operator()`](https://auscaster.com/icey/docs/api-reference/icy-ConstClassDelegate.md#operator-11)

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `args` | `Args...` | Arguments forwarded to the wrapped function. |

---

<a id="operator-2"></a>

### operator==

`virtual` `const`

```cpp
virtual bool operator==(const AbstractDelegate< RT, Args... > & that) const
```

[Defined in src/base/include/icy/delegate.h:41](https://github.com/auscaster/icey/blob/main/src/base/include/icy/delegate.h#L41)

Compares two delegates for equality (same target function and instance). 
#### Returns
True if both delegates refer to the same callable target.

#### Reimplemented by

- [`FunctionDelegate::operator==`](https://auscaster.com/icey/docs/api-reference/icy-FunctionDelegate.md#operator-29)
- [`ClassDelegate::operator==`](https://auscaster.com/icey/docs/api-reference/icy-ClassDelegate.md#operator-8)
- [`ConstClassDelegate::operator==`](https://auscaster.com/icey/docs/api-reference/icy-ConstClassDelegate.md#operator-12)

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `that` | const [`AbstractDelegate`](#abstractdelegate)< RT, Args... > & | Other delegate to compare against. |
