16 template<
typename result_t>
29 template<
typename result_t>
30 class delegate<result_t()> :
public object {
39 delegate(
const delegate& delegate) noexcept : functions_(delegate.functions_) {}
41 delegate(
const function_t& function)
noexcept { functions_.push_back(function); }
42 delegate& operator=(
const delegate& delegate)
noexcept {
43 functions_ = delegate.functions_;
51 template<
typename object1_t,
typename object2_t>
52 delegate(
const object1_t&
object, result_t(object2_t::*method)() const) noexcept {
53 functions_.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
58 template<
typename object1_t,
typename object2_t>
59 delegate(
const object1_t&
object, result_t(object2_t::*method)()) noexcept {
60 functions_.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
67 if (functions_.size() == 0)
return result_t();
69 for (
size_t i = 0;
i < functions_.size() - 1;
i++) {
74 return functions_.back()();
79 const std::vector<function_t>&
functions()
const {
return functions_;}
82 void clear() {functions_.clear();}
87 result_t
invoke()
const {
return operator()(); }
94 static delegate
combine(
const std::vector<delegate>& delegates)
noexcept {
96 for (
const delegate& delegate : delegates) {
97 for (
const function_t& function : delegate.functions_)
98 result.functions_.push_back(function);
108 static delegate
combine(
const delegate& a,
const delegate& b)
noexcept {
111 result.functions_.push_back(function);
117 bool is_empty() const noexcept {
return functions_.size() == 0; }
124 static delegate
remove(
const delegate& source,
const delegate& value)
noexcept {
125 delegate result = source;
126 for (
const function_t& function : value.functions_) {
127 if (find(result.functions_.begin(), result.functions_.end(), function) != result.functions_.end()) {
128 for (
typename std::vector<function_t>::reverse_iterator iterator = result.functions_.rbegin(); iterator != result.functions_.rend(); ++iterator) {
129 if (are_equals(*iterator, function)) {
130 result.functions_.erase((iterator + 1).base());
144 static delegate
remove_all(
const delegate& source,
const delegate& value)
noexcept {
145 delegate result = source;
146 for (
const function_t& function : value.functions_) {
147 if (find(result.functions_.begin(), result.functions_.end(), function) != result.functions_.end()) {
148 for (
typename std::vector<function_t>::reverse_iterator iterator = result.functions_.rbegin(); iterator != result.functions_.rend(); ++iterator) {
149 if (are_equals(*iterator, function)) {
150 result.functions_.erase((iterator + 1).base());
161 bool operator ==(
const delegate& delegate)
const noexcept {
162 if (functions_.size() != delegate.functions_.size())
165 for (
size_t i = 0;
i < functions_.size();
i++)
166 if (!are_equals(functions_[
i], delegate.functions_[
i]))
175 bool operator !=(
const delegate& delegate)
const {
return !operator==(delegate); }
177 delegate& operator=(
const function_t& function)
noexcept {
179 functions_.push_back(function);
184 delegate& operator+=(
const delegate& delegate)
noexcept {
185 *
this = delegate::combine(*
this, delegate);
189 delegate& operator+=(
const function_t& function)
noexcept {
190 *
this = delegate::combine(*
this, delegate(function));
194 delegate& operator-=(
const delegate& delegate)
noexcept {
195 *
this = delegate::remove(*
this, delegate);
199 delegate& operator-=(
const function_t& function)
noexcept {
200 *
this = delegate::remove(*
this, delegate(function));
204 template<
typename fn_t>
205 delegate& operator-=(fn_t function)
noexcept {
206 *
this = delegate::remove(*
this, delegate(function));
212 static bool are_equals(
const std::function<result_t()>& fct1,
const std::function<result_t()>& fct2)
noexcept {
213 return fct1.target_type() == fct2.target_type() && (fct1.template target<result_t(*)()>() == fct2.template target<result_t(*)()>() || *fct1.template target<result_t(*)()>() == *fct2.template target<result_t(*)()>());
216 static typename std::vector<function_t>::const_iterator find(
typename std::vector<function_t>::const_iterator begin,
typename std::vector<function_t>::const_iterator end,
const function_t& function)
noexcept {
217 for (
typename std::vector<function_t>::const_iterator iterator = begin; iterator !=
end; ++iterator)
218 if (are_equals(*iterator, function))
223 std::vector<function_t> functions_;
235 template<
typename result_t,
typename... arguments_t>
236 class delegate<result_t(arguments_t...)> :
public object {
247 delegate(
const delegate& delegate) noexcept : no_arguments_functions_(delegate.no_arguments_functions_), functions_(delegate.functions_) {}
249 delegate& operator=(
const delegate& delegate)
noexcept {
250 no_arguments_functions_ = delegate.no_arguments_functions_;
251 functions_ = delegate.functions_;
254 delegate(
const delegate<result_t()>& delegate) noexcept : no_arguments_functions_(delegate.functions()) {}
262 delegate(
const no_arguments_function_t& function)
noexcept { no_arguments_functions_.push_back(function); }
268 template<
typename object1_t,
typename object2_t>
269 delegate(
const object1_t&
object, result_t(object2_t::*method)() const) noexcept {
270 functions_.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
276 template<
typename object1_t,
typename object2_t>
277 delegate(
const object1_t&
object, result_t(object2_t::*method)()) noexcept {
278 functions_.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
282 template<
typename object1_t,
typename object2_t,
typename a1_t>
283 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t) const) noexcept {
284 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1)));
287 template<
typename object1_t,
typename object2_t,
typename a1_t>
288 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t)) noexcept {
289 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1)));
292 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t>
293 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t) const) noexcept {
294 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2)));
297 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t>
298 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t)) noexcept {
299 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2)));
302 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t>
303 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t) const) noexcept {
304 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
307 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t>
308 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t)) noexcept {
309 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
312 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t>
313 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t) const) {
314 functions_.push_back(function_t(std::bind(method,
const_cast<object1_t*
>(&
object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)));
317 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t>
318 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t)) noexcept {
319 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)));
322 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5>
323 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5) const) noexcept {
324 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)));
327 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5>
328 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5)) {
329 functions_.push_back(function_t(std::bind(method,
const_cast<object1_t*
>(&
object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)));
332 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t>
333 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t) const) noexcept {
334 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)));
337 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t>
338 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t)) noexcept {
339 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)));
342 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t,
typename a7_t>
343 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t) const) noexcept {
344 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7)));
347 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t,
typename a7_t>
348 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t)) noexcept {
349 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7)));
352 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t,
typename a7_t,
typename a8_t>
353 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t) const) noexcept {
354 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8)));
357 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t,
typename a7_t,
typename a8_t>
358 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t)) noexcept {
359 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8)));
362 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t,
typename a7_t,
typename a8_t,
typename a9_t>
363 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t, a9_t) const) noexcept {
364 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9)));
367 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t,
typename a7_t,
typename a8_t,
typename a9_t>
368 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t, a9_t)) noexcept {
369 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9)));
372 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t,
typename a7_t,
typename a8_t,
typename a9_t,
typename a10_t>
373 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t, a9_t, a10_t) const) noexcept {
374 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9, std::placeholders::_10)));
377 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t,
typename a7_t,
typename a8_t,
typename a9_t,
typename a10_t>
378 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t, a9_t, a10_t)) noexcept {
379 functions_.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9, std::placeholders::_10)));
387 if (no_arguments_functions_.size() == 0 && functions_.size() == 0)
return result_t();
389 if (no_arguments_functions_.size()) {
390 for (
size_t i = 0;
i < no_arguments_functions_.size() - (functions_.size() == 0 ? 1 : 0);
i++) {
392 no_arguments_functions_[
i]();
395 if (functions_.size() == 0) {
397 return no_arguments_functions_.back()();
401 for (
size_t i = 0;
i < functions_.size() - 1;
i++) {
403 functions_[
i](arguments...);
406 return functions_.back()(arguments...);
415 const std::vector<function_t>&
functions()
const {
return functions_;}
419 no_arguments_functions_.clear();
426 result_t
invoke(arguments_t... arguments)
const {
return operator()(arguments...); }
433 static delegate
combine(
const std::vector<delegate>& delegates)
noexcept {
435 for (
const delegate& delegate : delegates) {
437 result.no_arguments_functions_.push_back(function);
438 for (
const function_t& function : delegate.functions_)
439 result.functions_.push_back(function);
449 static delegate
combine(
const delegate& a,
const delegate& b)
noexcept {
452 result.no_arguments_functions_.push_back(function);
454 result.functions_.push_back(function);
460 bool is_empty() const noexcept {
return functions_.size() == 0 && no_arguments_functions_.size() == 0; }
467 static delegate
remove(
const delegate& source,
const delegate& value)
noexcept {
468 delegate result = source;
470 if (find(result.no_arguments_functions_.begin(), result.no_arguments_functions_.end(), function) != result.no_arguments_functions_.end()) {
471 for (
typename std::vector<no_arguments_function_t>::reverse_iterator iterator = result.no_arguments_functions_.rbegin(); iterator != result.no_arguments_functions_.rend(); ++iterator) {
472 if (are_equals(*iterator, function)) {
473 result.no_arguments_functions_.erase((iterator + 1).base());
480 for (
const function_t& function : value.functions_) {
481 if (find(result.functions_.begin(), result.functions_.end(), function) != result.functions_.end()) {
482 for (
typename std::vector<function_t>::reverse_iterator iterator = result.functions_.rbegin(); iterator != result.functions_.rend(); ++iterator) {
483 if (are_equals(*iterator, function)) {
484 result.functions_.erase((iterator + 1).base());
498 static delegate
remove_all(
const delegate& source,
const delegate& value)
noexcept {
499 delegate result = source;
501 if (find(result.no_arguments_functions_.begin(), result.no_arguments_functions_.end(), function) != result.no_arguments_functions_.end()) {
502 for (
typename std::vector<function_t>::reverse_iterator iterator = result.no_arguments_functions_.rbegin(); iterator != result.no_arguments_functions_.rend(); ++iterator) {
503 if (are_equals(*iterator, function)) {
504 result.no_arguments_functions_.erase((iterator + 1).base());
510 for (
const function_t& function : value.functions_) {
511 if (find(result.functions_.begin(), result.functions_.end(), function) != result.functions_.end()) {
512 for (
typename std::vector<function_t>::reverse_iterator iterator = result.functions_.rbegin(); iterator != result.functions_.rend(); ++iterator) {
513 if (are_equals(*iterator, function)) {
514 result.functions_.erase((iterator + 1).base());
526 if (functions_.size() != delegate.functions_.size() || no_arguments_functions_.size() != delegate.no_arguments_functions_.size())
529 for (
size_t i = 0;
i < no_arguments_functions_.size();
i++)
530 if (!are_equals(no_arguments_functions_[
i], delegate.no_arguments_functions_[
i]))
533 for (
size_t i = 0;
i < functions_.size();
i++)
534 if (!are_equals(functions_[
i], delegate.functions_[
i]))
543 bool operator!=(
const delegate& delegate)
const {
return !operator==(delegate); }
546 template<
typename type_t>
547 delegate& operator=(
const type_t& function)
noexcept {
548 no_arguments_functions_.clear();
550 functions_.push_back(function_t(function));
554 delegate& operator=(
const function_t& function)
noexcept {
555 no_arguments_functions_.clear();
557 functions_.push_back(function);
561 delegate& operator=(
const no_arguments_function_t& function)
noexcept {
562 no_arguments_functions_.clear();
564 no_arguments_functions_.push_back(function);
568 delegate& operator+=(
const delegate& delegate)
noexcept {
569 *
this = delegate::combine(*
this, delegate);
573 delegate& operator+=(
const no_arguments_function_t& function)
noexcept {
574 *
this = delegate::combine(*
this, delegate(function));
578 delegate& operator+=(
const function_t& function)
noexcept {
579 *
this = delegate::combine(*
this, delegate(function));
583 template<
typename fn_t>
584 delegate& operator+=(fn_t function)
noexcept {
585 *
this = delegate::combine(*
this, delegate(function));
589 delegate& operator-=(
const delegate& delegate)
noexcept {
590 *
this = delegate::remove(*
this, delegate);
594 delegate& operator-=(
const no_arguments_function_t& function)
noexcept {
595 *
this = delegate::remove(*
this, delegate(function));
599 delegate& operator-=(
const function_t& function)
noexcept {
600 *
this = delegate::remove(*
this, delegate(function));
604 template<
typename fn_t>
605 delegate& operator-=(fn_t function)
noexcept {
606 *
this = delegate::remove(*
this, delegate(function));
612 static bool are_equals(
const std::function<result_t(arguments_t...)>& fct1,
const std::function<result_t(arguments_t...)>& fct2)
noexcept {
613 return fct1.target_type() == fct2.target_type() && (fct1.template target<result_t(*)(arguments_t...)>() == fct2.template target<result_t(*)(arguments_t...)>() || *fct1.template target<result_t(*)(arguments_t...)>() == *fct2.template target<result_t(*)(arguments_t...)>());
616 static bool are_equals(
const std::function<result_t()>& fct1,
const std::function<result_t()>& fct2)
noexcept {
617 return fct1.target_type() == fct2.target_type() && (fct1.template target<result_t(*)()>() == fct2.template target<result_t(*)()>() || *fct1.template target<result_t(*)()>() == *fct2.template target<result_t(*)()>());
620 static typename std::vector<no_arguments_function_t>::const_iterator find(
typename std::vector<no_arguments_function_t>::const_iterator begin,
typename std::vector<no_arguments_function_t>::const_iterator end,
const no_arguments_function_t& function)
noexcept {
621 for (
typename std::vector<no_arguments_function_t>::const_iterator iterator = begin; iterator !=
end; ++iterator)
622 if (are_equals(*iterator, function))
627 static typename std::vector<function_t>::const_iterator find(
typename std::vector<function_t>::const_iterator begin,
typename std::vector<function_t>::const_iterator end,
const function_t& function)
noexcept {
628 for (
typename std::vector<function_t>::const_iterator iterator = begin; iterator !=
end; ++iterator)
629 if (are_equals(*iterator, function))
634 std::vector<no_arguments_function_t> no_arguments_functions_;
635 std::vector<function_t> functions_;
Contains xtd::argument_null_exception exception.
The exception that is thrown when one of the arguments provided to a method is null.
Definition argument_null_exception.h:18
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.
Definition delegate.h:59
static delegate remove_all(const delegate &source, const delegate &value) noexcept
removes all occurrences of the invocation list of a delegate from the invocation list of another dele...
Definition delegate.h:144
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.
Definition delegate.h:52
void clear()
Clear delegates array.
Definition delegate.h:82
delegate()=default
Initializes an empty delegate.
delegate(const delegate &delegate) noexcept
Initializes a delegate that invokes the specified delegate instance.
Definition delegate.h:39
static delegate combine(const std::vector< delegate > &delegates) noexcept
Concatenates the invocation lists of an array of delegates.
Definition delegate.h:94
bool is_empty() const noexcept
Return if the delegate is empty.
Definition delegate.h:117
const std::vector< function_t > & functions() const
Gets the delegates array.
Definition delegate.h:79
std::function< result_t()> function_t
function_t pointer type
Definition delegate.h:33
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition delegate.h:108
result_t invoke() const
invokes the method represented by the current delegate.
Definition delegate.h:87
static delegate remove(const delegate &source, const delegate &value) noexcept
removes the last occurrence of the invocation list of a delegate from the invocation list of another ...
Definition delegate.h:124
result_t operator()() const
invokes the method represented by the current delegate.
Definition delegate.h:66
std::function< result_t()> no_arguments_function_t
no_arguments_function_t pointer type
Definition delegate.h:239
const std::vector< function_t > & functions() const
Gets the delegates array.
Definition delegate.h:415
void clear()
Clear delegates array.
Definition delegate.h:418
result_t invoke(arguments_t... arguments) const
invokes the method represented by the current delegate.
Definition delegate.h:426
static delegate combine(const std::vector< delegate > &delegates) noexcept
Concatenates the invocation lists of an array of delegates.
Definition delegate.h:433
delegate()=default
Initializes an empty delegate.
const std::vector< no_arguments_function_t > & no_arguments_functions() const
Gets the no arguments delegates array.
Definition delegate.h:411
std::function< result_t(arguments_t...)> function_t
function_t pointer type
Definition delegate.h:241
bool operator==(const delegate &delegate) const noexcept
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.h:525
bool operator!=(const delegate &delegate) const
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.h:543
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.
Definition delegate.h:277
result_t operator()(arguments_t... arguments) const
invokes the method represented by the current delegate.
Definition delegate.h:386
bool is_empty() const noexcept
Return if the delegate is empty.
Definition delegate.h:460
static delegate remove(const delegate &source, const delegate &value) noexcept
removes the last occurrence of the invocation list of a delegate from the invocation list of another ...
Definition delegate.h:467
delegate(const delegate &delegate) noexcept
Initializes a delegate that invokes the specified delegate instance.
Definition delegate.h:247
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition delegate.h:449
static delegate remove_all(const delegate &source, const delegate &value) noexcept
removes all occurrences of the invocation list of a delegate from the invocation list of another dele...
Definition delegate.h:498
delegate(const function_t &function) noexcept
Initializes a delegate that invokes the specified instance method.
Definition delegate.h:259
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.
Definition delegate.h:269
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:26
#define current_stack_frame_
Provides information about the current stack frame.
Definition stack_frame.h:201
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Contains xtd::object class.