16 template<
typename result_t>
29 template<
typename result_t>
30 class delegate<result_t()> :
public object {
47 data_->functions = delegate.data_->functions;
50 delegate(
const function_t&
function) noexcept { data_->functions.push_back(
function); }
51 delegate& operator=(
const delegate& delegate) noexcept {
52 data_->functions = delegate.data_->functions;
60 template<
typename object1_t,
typename object2_t>
61 delegate(
const object1_t&
object, result_t(object2_t::*method)()
const) noexcept {
62 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
67 template<
typename object1_t,
typename object2_t>
68 delegate(
const object1_t&
object, result_t(object2_t::*method)()) noexcept {
69 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
78 const std::vector<function_t>&
functions()
const {
return data_->functions;}
81 void clear() {data_->functions.clear();}
86 result_t
invoke()
const {
return operator()(); }
93 static delegate
combine(
const std::vector<delegate>& delegates) noexcept {
95 for (
const delegate& delegate : delegates) {
96 for (
const function_t&
function : delegate.data_->functions)
97 result.data_->functions.push_back(
function);
107 static delegate
combine(
const delegate&
a,
const delegate&
b) noexcept {
109 for (
const function_t&
function :
b.data_->functions)
110 result.data_->functions.push_back(
function);
116 bool is_empty() const noexcept {
return data_->functions.size() == 0; }
120 size_t size() const noexcept {
return data_->functions.size(); }
127 static delegate
remove(
const delegate& source,
const delegate& value) noexcept {
128 delegate result = source;
129 for (
const function_t&
function : value.data_->functions) {
130 if (find(result.data_->functions.begin(), result.data_->functions.end(),
function) != result.data_->functions.end()) {
131 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
132 if (are_equals(*iterator,
function)) {
133 result.data_->functions.erase((iterator + 1).base());
147 static delegate
remove_all(
const delegate& source,
const delegate& value) noexcept {
148 delegate result = source;
149 for (
const function_t&
function : value.data_->functions) {
150 if (find(result.data_->functions.begin(), result.data_->functions.end(),
function) != result.data_->functions.end()) {
151 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
152 if (are_equals(*iterator,
function))
153 result.data_->functions.erase((iterator + 1).base());
168 if (data_->functions.size() == 0)
return result_t();
170 for (
size_t i = 0;
i < data_->functions.size() - 1;
i++) {
172 data_->functions[
i]();
175 return data_->functions.back()();
181 bool operator ==(
const delegate& delegate)
const noexcept {
182 if (data_->functions.size() != delegate.data_->functions.size())
185 for (
size_t i = 0;
i < data_->functions.size();
i++)
186 if (!are_equals(data_->functions[
i], delegate.data_->functions[
i]))
195 bool operator !=(
const delegate& delegate)
const {
return !operator==(delegate); }
197 delegate& operator=(
const function_t&
function) noexcept {
198 data_->functions.clear();
199 data_->functions.push_back(
function);
205 delegate operator+(
const delegate&
other) noexcept {
206 delegate result = *
this;
211 delegate operator+(
const function_t&
function) noexcept {
212 delegate result = *
this;
217 delegate& operator+=(
const delegate& delegate) noexcept {
218 *
this = delegate::combine(*
this, delegate);
222 delegate& operator+=(
const function_t&
function) noexcept {
223 *
this = delegate::combine(*
this, delegate(
function));
227 delegate operator-(
const delegate& other) noexcept {
228 delegate result = *
this;
233 delegate operator-(
const function_t&
function) noexcept {
234 delegate result = *
this;
239 delegate& operator-=(
const delegate& delegate) noexcept {
240 *
this = delegate::remove(*
this, delegate);
244 delegate& operator-=(
const function_t&
function) noexcept {
245 *
this = delegate::remove(*
this, delegate(
function));
249 template<
typename fn_t>
250 delegate& operator-=(fn_t
function) noexcept {
251 *
this = delegate::remove(*
this, delegate(
function));
257 static bool are_equals(
const std::function<result_t()>& fct1,
const std::function<result_t()>& fct2) noexcept {
258 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(*)()>());
261 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 {
262 for (
typename std::vector<function_t>::const_iterator iterator = begin; iterator !=
end; ++iterator)
263 if (are_equals(*iterator,
function))
269 std::vector<function_t> functions;
271 std::shared_ptr<data> data_ = std::make_shared<data>();
283 template<
typename result_t,
typename... arguments_t>
284 class delegate<result_t(arguments_t...)> :
public object {
299 delegate() =
default;
303 data_->no_arguments_functions = delegate.data_->no_arguments_functions;
304 data_->functions = delegate.data_->functions;
307 delegate& operator=(
const delegate& delegate) noexcept {
308 data_->no_arguments_functions = delegate.data_->no_arguments_functions;
309 data_->functions = delegate.data_->functions;
312 delegate(
const delegate<result_t()>& delegate) noexcept {
313 data_->no_arguments_functions = delegate.functions();
322 delegate(
const no_arguments_function_t&
function) noexcept { data_->no_arguments_functions.push_back(
function); }
328 template<
typename object1_t,
typename object2_t>
329 delegate(
const object1_t&
object, result_t(object2_t::*method)()
const) noexcept {
330 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
336 template<
typename object1_t,
typename object2_t>
337 delegate(
const object1_t&
object, result_t(object2_t::*method)()) noexcept {
338 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
343 template<
typename object1_t,
typename object2_t,
typename a1_t>
344 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t)
const) noexcept {
345 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1)));
348 template<
typename object1_t,
typename object2_t,
typename a1_t>
349 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t)) noexcept {
350 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1)));
353 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t>
354 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t)
const) noexcept {
355 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1, std::placeholders::_2)));
358 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t>
359 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t)) noexcept {
360 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1, std::placeholders::_2)));
363 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t>
364 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t)
const) noexcept {
365 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
368 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t>
369 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t)) noexcept {
370 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
373 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t>
374 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t)
const) {
375 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)));
378 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t>
379 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t)) noexcept {
380 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)));
383 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5>
384 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5)
const) noexcept {
385 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)));
388 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5>
389 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5)) {
390 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)));
393 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t>
394 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t)
const) noexcept {
395 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)));
398 template<
typename object1_t,
typename object2_t,
typename a1_t,
typename a2_t,
typename a3_t,
typename a4_t,
typename A5,
typename a6_t>
399 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t)) noexcept {
400 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)));
403 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>
404 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 {
405 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)));
408 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>
409 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t)) noexcept {
410 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)));
413 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>
414 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 {
415 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)));
418 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>
419 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 {
420 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)));
423 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>
424 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 {
425 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)));
428 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>
429 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 {
430 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)));
433 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>
434 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 {
435 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)));
438 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>
439 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 {
440 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)));
453 const std::vector<function_t>&
functions()
const {
return data_->functions;}
457 data_->no_arguments_functions.clear();
458 data_->functions.clear();
464 result_t
invoke(arguments_t... arguments)
const {
return operator()(arguments...); }
471 static delegate
combine(
const std::vector<delegate>& delegates) noexcept {
473 for (
const delegate& delegate : delegates) {
475 result.data_->no_arguments_functions.push_back(
function);
476 for (
const function_t&
function : delegate.data_->functions)
477 result.data_->functions.push_back(
function);
487 static delegate
combine(
const delegate&
a,
const delegate&
b) noexcept {
490 result.data_->no_arguments_functions.push_back(
function);
491 for (
const function_t&
function :
b.data_->functions)
492 result.data_->functions.push_back(
function);
498 bool is_empty() const noexcept {
return data_->functions.size() == 0 && data_->no_arguments_functions.size() == 0; }
502 size_t size() const noexcept {
return data_->functions.size() + data_->no_arguments_functions.size(); }
509 static delegate
remove(
const delegate& source,
const delegate& value) noexcept {
510 delegate result = source;
512 if (find(result.data_->no_arguments_functions.begin(), result.data_->no_arguments_functions.end(),
function) != result.data_->no_arguments_functions.end()) {
513 for (
typename std::vector<no_arguments_function_t>::reverse_iterator iterator = result.data_->no_arguments_functions.rbegin(); iterator != result.data_->no_arguments_functions.rend(); ++iterator) {
514 if (are_equals(*iterator,
function)) {
515 result.data_->no_arguments_functions.erase((iterator + 1).base());
522 for (
const function_t&
function : value.data_->functions) {
523 if (find(result.data_->functions.begin(), result.data_->functions.end(),
function) != result.data_->functions.end()) {
524 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
525 if (are_equals(*iterator,
function)) {
526 result.data_->functions.erase((iterator + 1).base());
540 static delegate
remove_all(
const delegate& source,
const delegate& value) noexcept {
541 delegate result = source;
543 if (find(result.data_->no_arguments_functions.begin(), result.data_->no_arguments_functions.end(),
function) != result.data_->no_arguments_functions.end()) {
544 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->no_arguments_functions.rbegin(); iterator != result.data_->no_arguments_functions.rend(); ++iterator) {
545 if (are_equals(*iterator,
function))
546 result.data_->no_arguments_functions.erase((iterator + 1).base());
551 for (
const function_t&
function : value.data_->functions) {
552 if (find(result.data_->functions.begin(), result.data_->functions.end(),
function) != result.data_->functions.end()) {
553 for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
554 if (are_equals(*iterator,
function))
555 result.data_->functions.erase((iterator + 1).base());
570 if (data_->no_arguments_functions.size() == 0 && data_->functions.size() == 0)
return result_t();
572 if (data_->no_arguments_functions.size()) {
573 for (
size_t i = 0;
i < data_->no_arguments_functions.size() - (data_->functions.size() == 0 ? 1 : 0);
i++) {
575 data_->no_arguments_functions[
i]();
578 if (data_->functions.size() == 0) {
580 return data_->no_arguments_functions.back()();
584 for (
size_t i = 0;
i < data_->functions.size() - 1;
i++) {
586 data_->functions[
i](arguments...);
589 return data_->functions.back()(arguments...);
596 if (data_->functions.size() != delegate.data_->functions.size() || data_->no_arguments_functions.size() != delegate.data_->no_arguments_functions.size())
599 for (
size_t i = 0;
i < data_->no_arguments_functions.size();
i++)
600 if (!are_equals(data_->no_arguments_functions[
i], delegate.data_->no_arguments_functions[
i]))
603 for (
size_t i = 0;
i < data_->functions.size();
i++)
604 if (!are_equals(data_->functions[
i], delegate.data_->functions[
i]))
613 bool operator!=(
const delegate& delegate)
const {
return !operator==(delegate); }
617 template<
typename type_t>
618 delegate& operator=(
const type_t&
function) noexcept {
619 data_->no_arguments_functions.clear();
620 data_->functions.clear();
621 data_->functions.push_back(
function_t(
function));
625 delegate& operator=(
const function_t&
function) noexcept {
626 data_->no_arguments_functions.clear();
627 data_->functions.clear();
628 data_->functions.push_back(
function);
633 data_->no_arguments_functions.clear();
634 data_->functions.clear();
635 data_->no_arguments_functions.push_back(
function);
639 delegate operator+(
const delegate&
other) noexcept {
640 delegate result = *
this;
646 delegate result = *
this;
651 delegate operator+(
const function_t&
function) noexcept {
652 delegate result = *
this;
657 template<
typename fn_t>
658 delegate operator+(fn_t
function) noexcept {
659 delegate result = *
this;
664 delegate& operator+=(
const delegate& delegate) noexcept {
665 *
this = delegate::combine(*
this, delegate);
670 *
this = delegate::combine(*
this, delegate(
function));
674 delegate& operator+=(
const function_t&
function) noexcept {
675 *
this = delegate::combine(*
this, delegate(
function));
679 template<
typename fn_t>
680 delegate& operator+=(fn_t
function) noexcept {
681 *
this = delegate::combine(*
this, delegate(
function));
685 delegate operator-(
const delegate& other) noexcept {
686 delegate result = *
this;
692 delegate result = *
this;
697 delegate operator-(
const function_t&
function) noexcept {
698 delegate result = *
this;
703 template<
typename fn_t>
704 delegate operator-(fn_t
function) noexcept {
705 delegate result = *
this;
710 delegate& operator-=(
const delegate& delegate) noexcept {
711 *
this = delegate::remove(*
this, delegate);
716 *
this = delegate::remove(*
this, delegate(
function));
720 delegate& operator-=(
const function_t&
function) noexcept {
721 *
this = delegate::remove(*
this, delegate(
function));
725 template<
typename fn_t>
726 delegate& operator-=(fn_t
function) noexcept {
727 *
this = delegate::remove(*
this, delegate(
function));
733 static bool are_equals(
const std::function<result_t(arguments_t...)>& fct1,
const std::function<result_t(arguments_t...)>& fct2) noexcept {
734 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...)>());
737 static bool are_equals(
const std::function<result_t()>& fct1,
const std::function<result_t()>& fct2) noexcept {
738 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(*)()>());
741 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 {
742 for (
typename std::vector<no_arguments_function_t>::const_iterator iterator = begin; iterator !=
end; ++iterator)
743 if (are_equals(*iterator,
function))
748 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 {
749 for (
typename std::vector<function_t>::const_iterator iterator = begin; iterator !=
end; ++iterator)
750 if (are_equals(*iterator,
function))
755 std::vector<no_arguments_function_t> no_arguments_functions;
756 std::vector<function_t> functions;
758 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:18
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:329
result_t invoke(arguments_t... arguments) const
invokes the method represented by the current delegate.
Definition: delegate.h:464
std::function< result_t(arguments_t...)> function_t
function_t pointer type
Definition: delegate.h:292
size_t size() const noexcept
Return the size of invocation list.
Definition: delegate.h:120
size_t size() const noexcept
Return the size of invocation list.
Definition: delegate.h:502
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:61
std::function< result_t()> function_t
function_t pointer type
Definition: delegate.h:36
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition: delegate.h:107
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
bool is_empty() const noexcept
Return if the delegate is empty.
Definition: delegate.h:116
delegate(const delegate &delegate) noexcept
Initializes a delegate that invokes the specified delegate instance.
Definition: delegate.h:302
bool is_empty() const noexcept
Return if the delegate is empty.
Definition: delegate.h:498
#define current_stack_frame_
Provides information about the current stack frame.
Definition: stack_frame.h:219
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:337
bool operator==(const delegate &delegate) const noexcept
Determines whether this instance and another specified delegateType object have the same value...
Definition: delegate.h:595
delegate(const function_t &function) noexcept
Initializes a delegate that invokes the specified instance method.
Definition: delegate.h:319
void clear()
Clear delegates array.
Definition: delegate.h:456
result_t invoke() const
invokes the method represented by the current delegate.
Definition: delegate.h:86
static delegate combine(const std::vector< delegate > &delegates) noexcept
Concatenates the invocation lists of an array of delegates.
Definition: delegate.h:93
Contains xtd::argument_null_exception exception.
void clear()
Clear delegates array.
Definition: delegate.h:81
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:68
static delegate combine(const std::vector< delegate > &delegates) noexcept
Concatenates the invocation lists of an array of delegates.
Definition: delegate.h:471
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
std::function< result_t()> no_arguments_function_t
no_arguments_function_t pointer type
Definition: delegate.h:290
const std::vector< function_t > & functions() const
Gets the delegates array.
Definition: delegate.h:453
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:540
const std::vector< function_t > & functions() const
Gets the delegates array.
Definition: delegate.h:78
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:147
delegate(const delegate &delegate) noexcept
Initializes a delegate that invokes the specified delegate instance.
Definition: delegate.h:46
result_t operator()() const
invokes the method represented by the current delegate.
Definition: delegate.h:167
bool operator!=(const delegate &delegate) const
Determines whether this instance and another specified delegateType object have the same value...
Definition: delegate.h:613
result_t operator()(arguments_t... arguments) const
invokes the method represented by the current delegate.
Definition: delegate.h:569
const std::vector< no_arguments_function_t > & no_arguments_functions() const
Gets the no arguments delegates array.
Definition: delegate.h:449
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition: delegate.h:487