18 template<
typename result_t>
21 template<
typename result_t,
typename... arguments_t>
22 class delegate<result_t(arguments_t...)>;
48 template<
typename result_t>
51 std::vector<std::function <result_t()>> functions;
58 std::any async_state()
const noexcept
override;
60 bool completed_synchronously()
const noexcept
override;
61 bool is_completed()
const noexcept
override;
63 std::shared_ptr<data> data_;
82 data_->functions = delegate.data_->functions;
85 delegate(
const function_t&
function) noexcept {data_->functions.push_back(
function);}
86 delegate& operator =(
const delegate& delegate) noexcept {
87 data_->functions = delegate.data_->functions;
95 template<
typename object1_t,
typename object2_t>
96 delegate(
const object1_t&
object, result_t(object2_t::*method)()
const) noexcept {
97 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
102 template<
typename object1_t,
typename object2_t>
103 delegate(
const object1_t&
object, result_t(object2_t::*method)()) noexcept {
104 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
113 const std::vector<function_t>&
functions()
const {
return data_->functions;}
117 bool is_empty() const noexcept {
return data_->functions.size() == 0;}
121 size_t size() const noexcept {
return data_->functions.size();}
128 void clear() {data_->functions.clear();}
165 result_t
invoke()
const {
return operator()();}
172 static delegate
combine(
const std::vector<delegate>& delegates) noexcept {
174 for (
const delegate& delegate : delegates) {
175 for (
const function_t&
function : delegate.data_->functions)
176 result.data_->functions.push_back(
function);
186 static delegate
combine(
const delegate&
a,
const delegate&
b) noexcept {
188 for (
const function_t&
function :
b.data_->functions)
189 result.data_->functions.push_back(
function);
196 bool equals(
const delegate& delegate)
const noexcept
override {
197 if (data_->functions.size() != delegate.data_->functions.size())
200 for (
size_t i = 0;
i < data_->functions.size();
i++)
201 if (!are_equals(data_->functions[
i], delegate.data_->functions[
i]))
212 static delegate
remove(
const delegate& source,
const delegate& value) noexcept {
213 delegate result = source;
214 std::for_each(value.data_->functions.begin(), value.data_->functions.end(), [&](
auto function) {
215 auto iterator = std::find_if(result.data_->functions.rbegin(), result.data_->functions.rend(), [&](
auto item) {
return are_equals(item,
function);});
216 if (iterator != result.data_->functions.rend()) result.data_->functions.erase((iterator + 1).base());
226 static delegate
remove_all(
const delegate& source,
const delegate& value) noexcept {
227 delegate result = source;
228 for (
const function_t&
function : value.data_->functions) {
229 if (find(result.data_->functions.begin(), result.data_->functions.end(),
function) != result.data_->functions.end()) {
230 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
231 if (are_equals(*iterator,
function))
232 result.data_->functions.erase((iterator + 1).base());
247 if (data_->functions.size() == 0)
return result_t();
249 for (
size_t i = 0;
i < data_->functions.size() - 1;
i++) {
251 data_->functions[
i]();
254 return data_->functions.back()();
257 delegate& operator =(
const function_t&
function) noexcept {
258 data_->functions.clear();
259 data_->functions.push_back(
function);
265 delegate operator +(
const delegate&
other) noexcept {
266 delegate result = *
this;
271 delegate operator +(
const function_t&
function) noexcept {
272 delegate result = *
this;
277 template<
typename fn_t>
278 delegate operator +(fn_t
function) noexcept {
279 delegate result = *
this;
284 delegate& operator +=(
const delegate& delegate) noexcept {
285 *
this = delegate::combine(*
this, delegate);
289 delegate& operator +=(
const function_t&
function) noexcept {
290 *
this = delegate::combine(*
this, delegate(
function));
294 template<
typename fn_t>
295 delegate& operator +=(fn_t
function) noexcept {
296 *
this = delegate::combine(*
this, delegate(
function));
300 delegate operator -(
const delegate& other) noexcept {
301 delegate result = *
this;
306 delegate operator -(
const function_t&
function) noexcept {
307 delegate result = *
this;
312 template<
typename fn_t>
313 delegate operator -(fn_t
function) noexcept {
314 delegate result = *
this;
319 delegate& operator -=(
const delegate& delegate) noexcept {
320 *
this = delegate::remove(*
this, delegate);
324 delegate& operator -=(
const function_t&
function) noexcept {
325 *
this = delegate::remove(*
this, delegate(
function));
329 template<
typename fn_t>
330 delegate& operator -=(fn_t
function) noexcept {
331 *
this = delegate::remove(*
this, delegate(
function));
337 static bool are_equals(
const std::function<result_t()>& fct1,
const std::function<result_t()>& fct2) noexcept {
338 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(*)()>());
341 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 {
342 auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item,
function);});
343 if (iterator != end)
return iterator;
346 std::shared_ptr<data> data_ = std::make_shared<data>();
361 template<
typename result_t,
typename... arguments_t>
362 class delegate<result_t(arguments_t...)> :
public object,
public xtd::iequatable<delegate<result_t(arguments_t...)>> {
364 std::vector<std::function <result_t()>> no_arguments_functions;
365 std::vector<std::function <result_t(arguments_t...)>> functions;
372 std::any async_state()
const noexcept
override;
374 bool completed_synchronously()
const noexcept
override;
375 bool is_completed()
const noexcept
override;
377 std::shared_ptr<data> data_;
394 delegate() =
default;
398 data_->no_arguments_functions = delegate.data_->no_arguments_functions;
399 data_->functions = delegate.data_->functions;
402 delegate& operator =(
const delegate& delegate) noexcept {
403 data_->no_arguments_functions = delegate.data_->no_arguments_functions;
404 data_->functions = delegate.data_->functions;
407 delegate(
const delegate<result_t()>& delegate) noexcept {
408 data_->no_arguments_functions = delegate.functions();
417 delegate(
const no_arguments_function_t&
function) noexcept {data_->no_arguments_functions.push_back(
function);}
423 template<
typename object1_t,
typename object2_t>
424 delegate(
const object1_t&
object, result_t(object2_t::*method)()
const) noexcept {
425 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
431 template<
typename object1_t,
typename object2_t>
432 delegate(
const object1_t&
object, result_t(object2_t::*method)()) noexcept {
433 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
438 template<
typename object1_t,
typename object2_t,
typename a1_t>
439 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t)
const) noexcept {
440 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1)));
443 template<
typename object1_t,
typename object2_t,
typename a1_t>
444 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t)) noexcept {
445 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1)));
448 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t>
449 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t)
const) noexcept {
450 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1, std::placeholders::_2)));
453 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t>
454 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t)) noexcept {
455 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1, std::placeholders::_2)));
458 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t>
459 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t)
const) noexcept {
460 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
463 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t>
464 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t)) noexcept {
465 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
468 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t>
469 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t)
const) {
470 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)));
473 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t>
474 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t)) noexcept {
475 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)));
478 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5>
479 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5)
const) noexcept {
480 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)));
483 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5>
484 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5)) {
485 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)));
488 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t>
489 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t)
const) noexcept {
490 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)));
493 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t>
494 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t)) noexcept {
495 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)));
498 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>
499 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 {
500 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)));
503 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>
504 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t)) noexcept {
505 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)));
508 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>
509 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 {
510 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)));
513 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>
514 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 {
515 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)));
518 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>
519 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 {
520 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)));
523 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>
524 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 {
525 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)));
528 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>
529 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 {
530 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)));
533 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>
534 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 {
535 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)));
548 const std::vector<function_t>&
functions()
const {
return data_->functions;}
552 bool is_empty() const noexcept {
return data_->functions.size() == 0 && data_->no_arguments_functions.size() == 0;}
556 size_t size() const noexcept {
return data_->functions.size() + data_->no_arguments_functions.size();}
600 result_t
invoke(arguments_t... arguments)
const {
return operator()(arguments...);}
607 static delegate
combine(
const std::vector<delegate>& delegates) noexcept {
609 for (
const delegate& delegate : delegates) {
611 result.data_->no_arguments_functions.push_back(
function);
612 for (
const function_t&
function : delegate.data_->functions)
613 result.data_->functions.push_back(
function);
623 static delegate
combine(
const delegate&
a,
const delegate&
b) noexcept {
626 result.data_->no_arguments_functions.push_back(
function);
627 for (
const function_t&
function :
b.data_->functions)
628 result.data_->functions.push_back(
function);
635 bool equals(
const delegate& delegate)
const noexcept
override {
636 if (data_->functions.size() != delegate.data_->functions.size() || data_->no_arguments_functions.size() != delegate.data_->no_arguments_functions.size())
639 for (
size_t i = 0;
i < data_->no_arguments_functions.size();
i++)
640 if (!are_equals(data_->no_arguments_functions[
i], delegate.data_->no_arguments_functions[
i]))
643 for (
size_t i = 0;
i < data_->functions.size();
i++)
644 if (!are_equals(data_->functions[
i], delegate.data_->functions[
i]))
655 static delegate
remove(
const delegate& source,
const delegate& value) noexcept {
656 delegate result = source;
657 std::for_each(value.data_->no_arguments_functions.begin(), value.data_->no_arguments_functions.end(), [&](
auto no_arguments_function) {
658 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);});
659 if (iterator != result.data_->no_arguments_functions.rend()) result.data_->no_arguments_functions.erase((iterator + 1).base());
662 std::for_each(value.data_->functions.begin(), value.data_->functions.end(), [&](
auto function) {
663 auto iterator = std::find_if(result.data_->functions.rbegin(), result.data_->functions.rend(), [&](
auto item) {
return are_equals(item,
function);});
664 if (iterator != result.data_->functions.rend()) result.data_->functions.erase((iterator + 1).base());
674 static delegate
remove_all(
const delegate& source,
const delegate& value) noexcept {
675 delegate result = source;
677 if (find(result.data_->no_arguments_functions.begin(), result.data_->no_arguments_functions.end(),
function) != result.data_->no_arguments_functions.end()) {
678 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->no_arguments_functions.rbegin(); iterator != result.data_->no_arguments_functions.rend(); ++iterator) {
679 if (are_equals(*iterator,
function))
680 result.data_->no_arguments_functions.erase((iterator + 1).base());
685 for (
const function_t&
function : value.data_->functions) {
686 if (find(result.data_->functions.begin(), result.data_->functions.end(),
function) != result.data_->functions.end()) {
687 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
688 if (are_equals(*iterator,
function))
689 result.data_->functions.erase((iterator + 1).base());
704 if (data_->no_arguments_functions.size() == 0 && data_->functions.size() == 0)
return result_t();
706 if (data_->no_arguments_functions.size()) {
707 for (
size_t i = 0;
i < data_->no_arguments_functions.size() - (data_->functions.size() == 0 ? 1 : 0);
i++) {
709 data_->no_arguments_functions[
i]();
712 if (data_->functions.size() == 0) {
714 return data_->no_arguments_functions.back()();
718 for (
size_t i = 0;
i < data_->functions.size() - 1;
i++) {
720 data_->functions[
i](arguments...);
723 return data_->functions.back()(arguments...);
728 template<
typename type_t>
729 delegate& operator =(
const type_t&
function) noexcept {
730 data_->no_arguments_functions.clear();
731 data_->functions.clear();
732 data_->functions.push_back(
function_t(
function));
736 delegate& operator =(
const function_t&
function) noexcept {
737 data_->no_arguments_functions.clear();
738 data_->functions.clear();
739 data_->functions.push_back(
function);
744 data_->no_arguments_functions.clear();
745 data_->functions.clear();
746 data_->no_arguments_functions.push_back(
function);
750 delegate operator +(
const delegate&
other) noexcept {
751 delegate result = *
this;
757 delegate result = *
this;
762 delegate operator +(
const function_t&
function) noexcept {
763 delegate result = *
this;
768 template<
typename fn_t>
769 delegate operator +(fn_t
function) noexcept {
770 delegate result = *
this;
775 delegate& operator +=(
const delegate& delegate) noexcept {
776 *
this = delegate::combine(*
this, delegate);
781 *
this = delegate::combine(*
this, delegate(
function));
785 delegate& operator +=(
const function_t&
function) noexcept {
786 *
this = delegate::combine(*
this, delegate(
function));
790 template<
typename fn_t>
791 delegate& operator +=(fn_t
function) noexcept {
792 *
this = delegate::combine(*
this, delegate(
function));
796 delegate operator -(
const delegate& other) noexcept {
797 delegate result = *
this;
803 delegate result = *
this;
808 delegate operator -(
const function_t&
function) noexcept {
809 delegate result = *
this;
814 template<
typename fn_t>
815 delegate operator -(fn_t
function) noexcept {
816 delegate result = *
this;
821 delegate& operator -=(
const delegate& delegate) noexcept {
822 *
this = delegate::remove(*
this, delegate);
827 *
this = delegate::remove(*
this, delegate(
function));
831 delegate& operator -=(
const function_t&
function) noexcept {
832 *
this = delegate::remove(*
this, delegate(
function));
836 template<
typename fn_t>
837 delegate& operator -=(fn_t
function) noexcept {
838 *
this = delegate::remove(*
this, delegate(
function));
844 static bool are_equals(
const std::function<result_t(arguments_t...)>& fct1,
const std::function<result_t(arguments_t...)>& fct2) noexcept {
845 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...)>());
848 static bool are_equals(
const std::function<result_t()>& fct1,
const std::function<result_t()>& fct2) noexcept {
849 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(*)()>());
852 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 {
853 auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item,
function);});
854 if (iterator != end)
return iterator;
858 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 {
859 auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item,
function);});
860 if (iterator != end)
return iterator;
864 std::shared_ptr<data> data_ = std::make_shared<data>();
The exception that is thrown when one of the arguments provided to a method is null.
Definition: argument_null_exception.h:20
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:424
Contains xtd::iequatable interface.
delegate< void(async_result ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition: delegate.h:34
Represents the status of an asynchronous operation.
Definition: iasync_result.h:22
result_t invoke(arguments_t... arguments) const
invokes the method represented by the current delegate.
Definition: delegate.h:600
std::function< result_t(arguments_t...)> function_t
function_t pointer type
Definition: delegate.h:387
size_t size() const noexcept
Return the size of invocation list.
Definition: delegate.h:121
size_t size() const noexcept
Return the size of invocation list.
Definition: delegate.h:556
bool equals(const delegate &delegate) const noexcept override
Determines whether this instance and another specified delegateType object have the same value...
Definition: delegate.h:196
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:96
std::function< result_t()> function_t
function_t pointer type
Definition: delegate.h:71
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition: delegate.h:186
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
std::shared_ptr< xtd::iasync_result > async_result
Represents the status of an asynchronous operation.
Definition: async_result.h:16
bool is_empty() const noexcept
Return if the delegate is empty.
Definition: delegate.h:117
delegate(const delegate &delegate) noexcept
Initializes a delegate that invokes the specified delegate instance.
Definition: delegate.h:397
bool is_empty() const noexcept
Return if the delegate is empty.
Definition: delegate.h:552
#define csf_
Provides information about the current stack frame.
Definition: current_stack_frame.h:30
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:432
delegate(const function_t &function) noexcept
Initializes a delegate that invokes the specified instance method.
Definition: delegate.h:414
result_t invoke() const
invokes the method represented by the current delegate.
Definition: delegate.h:165
Contains xtd::object_ref alias.
static delegate combine(const std::vector< delegate > &delegates) noexcept
Concatenates the invocation lists of an array of delegates.
Definition: delegate.h:172
Contains std::any type and std::bad_any_cast exception.
Contains xtd::argument_null_exception exception.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
void clear()
Clear delegates array.
Definition: delegate.h:128
The operating system is other.
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:103
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
static delegate combine(const std::vector< delegate > &delegates) noexcept
Concatenates the invocation lists of an array of delegates.
Definition: delegate.h:607
bool equals(const delegate &delegate) const noexcept override
Determines whether this instance and another specified delegateType object have the same value...
Definition: delegate.h:635
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
std::function< result_t()> no_arguments_function_t
no_arguments_function_t pointer type
Definition: delegate.h:385
Contains xtd::async_result alias.
const std::vector< function_t > & functions() const
Gets the delegates array.
Definition: delegate.h:548
Contains xtd::threading::thread_pool class.
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:674
const std::vector< function_t > & functions() const
Gets the delegates array.
Definition: delegate.h:113
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:226
delegate(const delegate &delegate) noexcept
Initializes a delegate that invokes the specified delegate instance.
Definition: delegate.h:81
result_t operator()() const
invokes the method represented by the current delegate.
Definition: delegate.h:246
result_t operator()(arguments_t... arguments) const
invokes the method represented by the current delegate.
Definition: delegate.h:703
const std::vector< no_arguments_function_t > & no_arguments_functions() const
Gets the no arguments delegates array.
Definition: delegate.h:544
Encapsulates operating system specific objects that wait for exclusive access to shared resources...
Definition: wait_handle.h:48
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition: delegate.h:623