18 template<
class result_t>
21 template<
class result_t,
class ...arguments_t>
22 class delegate<result_t(arguments_t...)>;
55 template<
class result_t>
58 std::vector<std::function <result_t()>> functions;
65 std::any async_state()
const noexcept override;
67 bool completed_synchronously()
const noexcept override;
68 bool is_completed()
const noexcept override;
87 delegate(delegate&&) =
default;
88 delegate(
const delegate&) =
default;
89 delegate& operator =(
const delegate& delegate) =
default;
99 template<
class object1_t,
class object2_t>
100 delegate(
const object1_t&
object, result_t(object2_t::*method)() const) noexcept {
101 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
106 template<
class object1_t,
class object2_t>
107 delegate(
const object1_t&
object, result_t(object2_t::*method)()) noexcept {
108 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
117 const std::vector<function_t>&
functions()
const {
return data_->functions;}
121 bool is_empty() const noexcept {
return data_->functions.size() == 0;}
125 size_t size() const noexcept {
return data_->functions.size();}
132 void clear() {data_->functions.clear();}
169 result_t
invoke()
const {
return operator()();}
174 bool equals(
const object& obj)
const noexcept override {
return is<delegate>(obj) &&
equals(
static_cast<const delegate&
>(obj));}
178 bool equals(
const delegate& other)
const noexcept override {
179 if (data_->functions.size() !=
other.data_->functions.size())
182 for (
size_t i = 0;
i < data_->functions.size();
i++)
183 if (!are_equals(data_->functions[
i],
other.data_->functions[
i]))
198 static delegate
combine(
const std::vector<delegate>& delegates)
noexcept {
200 for (
const delegate& delegate : delegates) {
201 for (
const function_t& function : delegate.data_->functions)
202 result.data_->functions.push_back(function);
212 static delegate
combine(
const delegate& a,
const delegate& b)
noexcept {
214 for (
const function_t& function :
b.data_->functions)
215 result.data_->functions.push_back(function);
224 static delegate
remove(
const delegate& source,
const delegate& value)
noexcept {
225 delegate result = source;
226 std::for_each(value.data_->functions.begin(), value.data_->functions.end(), [&](
auto function) {
227 auto iterator = std::find_if(result.data_->functions.rbegin(), result.data_->functions.rend(), [&](auto item) {return are_equals(item, function);});
228 if (iterator != result.data_->functions.rend()) result.data_->functions.erase((iterator + 1).base());
238 static delegate
remove_all(
const delegate& source,
const delegate& value)
noexcept {
239 delegate result = source;
240 for (
const function_t& function : value.data_->functions) {
241 if (find(result.data_->functions.begin(), result.data_->functions.end(), function) != result.data_->functions.end()) {
242 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
243 if (are_equals(*iterator, function))
244 result.data_->functions.erase((iterator + 1).base());
259 if (data_->functions.size() == 0)
return result_t();
261 for (
size_t i = 0;
i < data_->functions.size() - 1;
i++) {
263 data_->functions[
i]();
266 return data_->functions.back()();
269 delegate& operator =(
const function_t& function)
noexcept {
270 data_->functions.clear();
271 data_->functions.push_back(function);
277 delegate operator +(
const delegate& other)
noexcept {
278 delegate result = *
this;
283 delegate operator +(
const function_t& function)
noexcept {
284 delegate result = *
this;
290 delegate operator +(fn_t function)
noexcept {
291 delegate result = *
this;
296 delegate& operator +=(
const delegate& delegate)
noexcept {
297 *
this = delegate::combine(*
this, delegate);
301 delegate& operator +=(
const function_t& function)
noexcept {
302 *
this = delegate::combine(*
this, delegate(function));
307 delegate& operator +=(fn_t function)
noexcept {
308 *
this = delegate::combine(*
this, delegate(function));
312 delegate operator -(
const delegate& other)
noexcept {
313 delegate result = *
this;
318 delegate operator -(
const function_t& function)
noexcept {
319 delegate result = *
this;
325 delegate operator -(fn_t function)
noexcept {
326 delegate result = *
this;
331 delegate& operator -=(
const delegate& delegate)
noexcept {
332 *
this = delegate::remove(*
this, delegate);
336 delegate& operator -=(
const function_t& function)
noexcept {
337 *
this = delegate::remove(*
this, delegate(function));
342 delegate& operator -=(fn_t function)
noexcept {
343 *
this = delegate::remove(*
this, delegate(function));
349 static bool are_equals(
const std::function<result_t()>& fct1,
const std::function<result_t()>& fct2)
noexcept {
350 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(*)()>());
353 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 {
354 auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item, function);});
355 if (iterator != end)
return iterator;
375 template<
class result_t,
class ...arguments_t>
376 class delegate<result_t(arguments_t...)> :
public object,
public xtd::iequatable<delegate<result_t(arguments_t...)>> {
378 std::vector<std::function <result_t()>> no_arguments_functions;
379 std::vector<std::function <result_t(arguments_t...)>> functions;
386 std::any async_state()
const noexcept override;
388 bool completed_synchronously()
const noexcept override;
389 bool is_completed()
const noexcept override;
410 delegate(delegate&&) =
default;
411 delegate(
const delegate&) =
default;
412 delegate& operator =(
const delegate& delegate) =
default;
413 delegate(
const delegate<result_t()>& delegate)
noexcept {data_->no_arguments_functions = delegate.functions();}
421 delegate(
const no_arguments_function_t& function)
noexcept {data_->no_arguments_functions.push_back(function);}
427 template<
class object1_t,
class object2_t>
428 delegate(
const object1_t&
object, result_t(object2_t::*method)() const) noexcept {
429 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
435 template<
class object1_t,
class object2_t>
436 delegate(
const object1_t&
object, result_t(object2_t::*method)()) noexcept {
437 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
442 template<
class object1_t,
class object2_t,
class a1_t>
443 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t) const) noexcept {
444 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1)));
447 template<
class object1_t,
class object2_t,
class a1_t>
448 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t)) noexcept {
449 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1)));
452 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t>
453 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t) const) noexcept {
454 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2)));
457 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t>
458 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t)) noexcept {
459 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2)));
462 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t>
463 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t) const) noexcept {
464 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
467 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t>
468 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t)) noexcept {
469 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
472 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t>
473 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t) const) {
474 data_->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)));
477 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t>
478 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t)) noexcept {
479 data_->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)));
482 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5>
483 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5) const) noexcept {
484 data_->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)));
487 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5>
488 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5)) {
489 data_->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)));
492 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t>
493 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t) const) noexcept {
494 data_->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)));
497 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t>
498 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t)) noexcept {
499 data_->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)));
502 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t>
503 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 {
504 data_->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)));
507 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t>
508 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t)) noexcept {
509 data_->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)));
512 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t>
513 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 {
514 data_->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)));
517 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t>
518 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 {
519 data_->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)));
522 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t,
class a9_t>
523 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 {
524 data_->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)));
527 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t,
class a9_t>
528 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 {
529 data_->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)));
532 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t,
class a9_t,
class a10_t>
533 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 {
534 data_->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)));
537 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t,
class a9_t,
class a10_t>
538 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 {
539 data_->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)));
552 const std::vector<function_t>&
functions()
const {
return data_->functions;}
556 bool is_empty() const noexcept {
return data_->functions.size() == 0 && data_->no_arguments_functions.size() == 0;}
560 size_t size() const noexcept {
return data_->functions.size() + data_->no_arguments_functions.size();}
604 result_t
invoke(arguments_t... arguments)
const {
return operator()(arguments...);}
609 bool equals(
const object& obj)
const noexcept override {
return is<delegate>(obj) &&
equals(
static_cast<const delegate&
>(obj));}
613 bool equals(
const delegate& other)
const noexcept override {
614 if (data_->functions.size() !=
other.data_->functions.size() || data_->no_arguments_functions.size() !=
other.data_->no_arguments_functions.size())
617 for (
size_t i = 0;
i < data_->no_arguments_functions.size();
i++)
618 if (!are_equals(data_->no_arguments_functions[
i],
other.data_->no_arguments_functions[
i]))
621 for (
size_t i = 0;
i < data_->functions.size();
i++)
622 if (!are_equals(data_->functions[
i],
other.data_->functions[
i]))
637 static delegate
combine(
const std::vector<delegate>& delegates)
noexcept {
639 for (
const delegate& delegate : delegates) {
641 result.data_->no_arguments_functions.push_back(function);
642 for (
const function_t& function : delegate.data_->functions)
643 result.data_->functions.push_back(function);
653 static delegate
combine(
const delegate& a,
const delegate& b)
noexcept {
656 result.data_->no_arguments_functions.push_back(function);
657 for (
const function_t& function :
b.data_->functions)
658 result.data_->functions.push_back(function);
667 static delegate
remove(
const delegate& source,
const delegate& value)
noexcept {
668 delegate result = source;
669 std::for_each(value.data_->no_arguments_functions.begin(), value.data_->no_arguments_functions.end(), [&](
auto no_arguments_function) {
670 auto iterator = std::find_if(result.data_->no_arguments_functions.rbegin(), result.data_->no_arguments_functions.rend(), [&](auto item) {return are_equals(item, no_arguments_function);});
671 if (iterator != result.data_->no_arguments_functions.rend()) result.data_->no_arguments_functions.erase((iterator + 1).base());
674 std::for_each(value.data_->functions.begin(), value.data_->functions.end(), [&](
auto function) {
675 auto iterator = std::find_if(result.data_->functions.rbegin(), result.data_->functions.rend(), [&](auto item) {return are_equals(item, function);});
676 if (iterator != result.data_->functions.rend()) result.data_->functions.erase((iterator + 1).base());
686 static delegate
remove_all(
const delegate& source,
const delegate& value)
noexcept {
687 delegate result = source;
689 if (find(result.data_->no_arguments_functions.begin(), result.data_->no_arguments_functions.end(), function) != result.data_->no_arguments_functions.end()) {
690 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->no_arguments_functions.rbegin(); iterator != result.data_->no_arguments_functions.rend(); ++iterator) {
691 if (are_equals(*iterator, function))
692 result.data_->no_arguments_functions.erase((iterator + 1).base());
697 for (
const function_t& function : value.data_->functions) {
698 if (find(result.data_->functions.begin(), result.data_->functions.end(), function) != result.data_->functions.end()) {
699 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
700 if (are_equals(*iterator, function))
701 result.data_->functions.erase((iterator + 1).base());
716 if (data_->no_arguments_functions.size() == 0 && data_->functions.size() == 0)
return result_t();
718 if (data_->no_arguments_functions.size()) {
719 for (
size_t i = 0;
i < data_->no_arguments_functions.size() - (data_->functions.size() == 0 ? 1 : 0);
i++) {
721 data_->no_arguments_functions[
i]();
724 if (data_->functions.size() == 0) {
726 return data_->no_arguments_functions.back()();
730 for (
size_t i = 0;
i < data_->functions.size() - 1;
i++) {
732 data_->functions[
i](arguments...);
735 return data_->functions.back()(arguments...);
740 template<
class type_t>
741 delegate& operator =(
const type_t& function)
noexcept {
742 data_->no_arguments_functions.clear();
743 data_->functions.clear();
744 data_->functions.push_back(function_t(function));
748 delegate& operator =(
const function_t& function)
noexcept {
749 data_->no_arguments_functions.clear();
750 data_->functions.clear();
751 data_->functions.push_back(function);
755 delegate& operator =(
const no_arguments_function_t& function)
noexcept {
756 data_->no_arguments_functions.clear();
757 data_->functions.clear();
758 data_->no_arguments_functions.push_back(function);
762 delegate operator +(
const delegate& other)
noexcept {
763 delegate result = *
this;
768 delegate operator +(
const no_arguments_function_t& function)
noexcept {
769 delegate result = *
this;
774 delegate operator +(
const function_t& function)
noexcept {
775 delegate result = *
this;
781 delegate operator +(fn_t function)
noexcept {
782 delegate result = *
this;
787 delegate& operator +=(
const delegate& delegate)
noexcept {
788 *
this = delegate::combine(*
this, delegate);
792 delegate& operator +=(
const no_arguments_function_t& function)
noexcept {
793 *
this = delegate::combine(*
this, delegate(function));
797 delegate& operator +=(
const function_t& function)
noexcept {
798 *
this = delegate::combine(*
this, delegate(function));
803 delegate& operator +=(fn_t function)
noexcept {
804 *
this = delegate::combine(*
this, delegate(function));
808 delegate operator -(
const delegate& other)
noexcept {
809 delegate result = *
this;
814 delegate operator -(
const no_arguments_function_t& function)
noexcept {
815 delegate result = *
this;
820 delegate operator -(
const function_t& function)
noexcept {
821 delegate result = *
this;
827 delegate operator -(fn_t function)
noexcept {
828 delegate result = *
this;
833 delegate& operator -=(
const delegate& delegate)
noexcept {
834 *
this = delegate::remove(*
this, delegate);
838 delegate& operator -=(
const no_arguments_function_t& function)
noexcept {
839 *
this = delegate::remove(*
this, delegate(function));
843 delegate& operator -=(
const function_t& function)
noexcept {
844 *
this = delegate::remove(*
this, delegate(function));
849 delegate& operator -=(fn_t function)
noexcept {
850 *
this = delegate::remove(*
this, delegate(function));
856 static bool are_equals(
const std::function<result_t(arguments_t...)>& fct1,
const std::function<result_t(arguments_t...)>& fct2)
noexcept {
857 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...)>());
860 static bool are_equals(
const std::function<result_t()>& fct1,
const std::function<result_t()>& fct2)
noexcept {
861 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(*)()>());
864 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 {
865 auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item, function);});
866 if (iterator != end)
return iterator;
870 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 {
871 auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item, function);});
872 if (iterator != end)
return iterator;
Contains std::any type and std::bad_any_cast exception.
Contains xtd::argument_null_exception exception.
Contains xtd::async_result alias.
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.hpp:107
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.hpp:238
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.hpp:100
void clear()
Clear delegates array.
Definition delegate.hpp:132
delegate()=default
Initializes an empty delegate.
static delegate combine(const std::vector< delegate > &delegates) noexcept
Concatenates the invocation lists of an array of delegates.
Definition delegate.hpp:198
bool equals(const delegate &other) const noexcept override
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.hpp:178
bool is_empty() const noexcept
Return if the delegate is empty.
Definition delegate.hpp:121
size_t size() const noexcept
Return the size of invocation list.
Definition delegate.hpp:125
async_result begin_invoke(xtd::async_callback async_callback)
Executes the method represented by the current delegate asynchronously on the thread that the control...
delegate(const function_t &function) noexcept
Initializes a delegate that invokes the specified instance method.
Definition delegate.hpp:94
const std::vector< function_t > & functions() const
Gets the delegates array.
Definition delegate.hpp:117
std::function< result_t()> function_t
function_t pointer type
Definition delegate.hpp:78
async_result begin_invoke(xtd::async_callback async_callback, std::any async_state)
Executes the method represented by the current delegate asynchronously on the thread that the control...
result_t end_invoke(async_result async)
Retrieves the return value of the asynchronous operation represented by the async_result_invoke passe...
bool equals(const object &obj) const noexcept override
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.hpp:174
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition delegate.hpp:212
result_t invoke() const
invokes the method represented by the current delegate.
Definition delegate.hpp:169
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.hpp:224
result_t operator()() const
invokes the method represented by the current delegate.
Definition delegate.hpp:258
async_result begin_invoke()
Executes the method represented by the current delegate asynchronously on the thread that the control...
std::function< result_t()> no_arguments_function_t
no_arguments_function_t pointer type
Definition delegate.hpp:399
const std::vector< function_t > & functions() const
Gets the delegates array.
Definition delegate.hpp:552
async_result begin_invoke(xtd::async_callback async_callback, std::any async_state, arguments_t... arguments)
Executes the method represented by the current delegate asynchronously on the thread that the control...
async_result begin_invoke(arguments_t... arguments)
Executes the method represented by the current delegate asynchronously on the thread that the control...
result_t invoke(arguments_t... arguments) const
invokes the method represented by the current delegate.
Definition delegate.hpp:604
result_t end_invoke(async_result async)
Retrieves the return value of the asynchronous operation represented by the async_result_invoke passe...
static delegate combine(const std::vector< delegate > &delegates) noexcept
Concatenates the invocation lists of an array of delegates.
Definition delegate.hpp:637
delegate()=default
Initializes an empty delegate.
bool equals(const delegate &other) const noexcept override
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.hpp:613
const std::vector< no_arguments_function_t > & no_arguments_functions() const
Gets the no arguments delegates array.
Definition delegate.hpp:548
std::function< result_t(arguments_t...)> function_t
function_t pointer type
Definition delegate.hpp:401
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.hpp:436
size_t size() const noexcept
Return the size of invocation list.
Definition delegate.hpp:560
result_t operator()(arguments_t... arguments) const
invokes the method represented by the current delegate.
Definition delegate.hpp:715
bool is_empty() const noexcept
Return if the delegate is empty.
Definition delegate.hpp:556
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.hpp:667
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition delegate.hpp:653
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.hpp:686
delegate(const function_t &function) noexcept
Initializes a delegate that invokes the specified instance method.
Definition delegate.hpp:418
async_result begin_invoke(xtd::async_callback async_callback, arguments_t... arguments)
Executes the method represented by the current delegate asynchronously on the thread that the control...
bool equals(const object &obj) const noexcept override
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.hpp:609
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.hpp:428
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
Represents the status of an asynchronous operation.
Definition iasync_result.hpp:25
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Encapsulates operating system specific objects that wait for exclusive access to shared resources.
Definition wait_handle.hpp:52
xtd::delegate< void(async_result ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition delegate.hpp:39
@ argument_null
The argument is null.
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
xtd::sptr< xtd::iasync_result > async_result
Represents the status of an asynchronous operation.
Definition async_result.hpp:19
@ other
The operating system is other.
Contains xtd::iequatable interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::object class.
Contains xtd::object_ref alias.
Contains xtd::threading::thread_pool class.