18  template<
typename result_t>
 
   21  template<
typename result_t, 
typename... arguments_t>
 
   22  class delegate<result_t(arguments_t...)>;
 
   52  template<
typename result_t>
 
   55      std::vector<std::function <result_t()>> functions;
 
   62      std::any async_state() 
const noexcept override;
 
   64      bool completed_synchronously() 
const noexcept override;
 
   65      bool is_completed() 
const noexcept override;
 
   84    delegate(delegate&&) = 
default;
 
   85    delegate(
const delegate&) = 
default;
 
   86    delegate& operator =(
const delegate& delegate) = 
default;
 
   96    template<
typename object1_t, 
typename object2_t>
 
   97    delegate(
const object1_t& 
object, result_t(object2_t::*method)() const) noexcept {
 
   98      data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
 
  103    template<
typename object1_t, 
typename object2_t>
 
  104    delegate(
const object1_t& 
object, result_t(object2_t::*method)()) noexcept {
 
  105      data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
 
  114    const std::vector<function_t>& 
functions()
 const {
return data_->functions;}
 
  118    bool is_empty() const noexcept {
return data_->functions.size() == 0;}
 
  122    size_t size() const noexcept {
return data_->functions.size();}
 
  129    void clear() {data_->functions.clear();}
 
  166    result_t 
invoke()
 const {
return operator()();}
 
  168    using object::equals;
 
  172    bool equals(
const delegate& delegate) 
const noexcept override {
 
  173      if (data_->functions.size() != delegate.data_->functions.size())
 
  176      for (
size_t i = 0; 
i < data_->functions.size(); 
i++)
 
  177        if (!are_equals(data_->functions[
i], delegate.data_->functions[
i]))
 
  192    static delegate 
combine(
const std::vector<delegate>& delegates) 
noexcept {
 
  194      for (
const delegate& delegate : delegates) {
 
  195        for (
const function_t& function : delegate.data_->functions)
 
  196          result.data_->functions.push_back(function);
 
  206    static delegate 
combine(
const delegate& a, 
const delegate& b) 
noexcept {
 
  208      for (
const function_t& function : 
b.data_->functions)
 
  209        result.data_->functions.push_back(function);
 
  218    static delegate 
remove(
const delegate& source, 
const delegate& value) 
noexcept {
 
  219      delegate result = source;
 
  220      std::for_each(value.data_->functions.begin(), value.data_->functions.end(), [&](
auto function) {
 
  221        auto iterator = std::find_if(result.data_->functions.rbegin(), result.data_->functions.rend(), [&](auto item) {return are_equals(item, function);});
 
  222        if (iterator != result.data_->functions.rend()) result.data_->functions.erase((iterator + 1).base());
 
  232    static delegate 
remove_all(
const delegate& source, 
const delegate& value) 
noexcept {
 
  233      delegate result = source;
 
  234      for (
const function_t& function : value.data_->functions) {
 
  235        if (find(result.data_->functions.begin(), result.data_->functions.end(), function) != result.data_->functions.end()) {
 
  236          for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
 
  237            if (are_equals(*iterator, function))
 
  238              result.data_->functions.erase((iterator + 1).base());
 
  253      if (data_->functions.size() == 0) 
return result_t();
 
  255      for (
size_t i = 0; 
i < data_->functions.size() - 1; 
i++) {
 
  257        data_->functions[
i]();
 
  260      return data_->functions.back()();
 
  263    delegate& operator =(
const function_t& function) 
noexcept {
 
  264      data_->functions.clear();
 
  265      data_->functions.push_back(function);
 
  271    delegate operator +(
const delegate& other) 
noexcept {
 
  272      delegate result = *
this;
 
  277    delegate operator +(
const function_t& function) 
noexcept {
 
  278      delegate result = *
this;
 
  283    template<
typename fn_t>
 
  284    delegate operator +(fn_t function) 
noexcept {
 
  285      delegate result = *
this;
 
  290    delegate& operator +=(
const delegate& delegate) 
noexcept {
 
  291      *
this = delegate::combine(*
this, delegate);
 
  295    delegate& operator +=(
const function_t& function) 
noexcept {
 
  296      *
this = delegate::combine(*
this, delegate(function));
 
  300    template<
typename fn_t>
 
  301    delegate& operator +=(fn_t function) 
noexcept {
 
  302      *
this = delegate::combine(*
this, delegate(function));
 
  306    delegate operator -(
const delegate& other) 
noexcept {
 
  307      delegate result = *
this;
 
  312    delegate operator -(
const function_t& function) 
noexcept {
 
  313      delegate result = *
this;
 
  318    template<
typename fn_t>
 
  319    delegate operator -(fn_t function) 
noexcept {
 
  320      delegate result = *
this;
 
  325    delegate& operator -=(
const delegate& delegate) 
noexcept {
 
  326      *
this = delegate::remove(*
this, delegate);
 
  330    delegate& operator -=(
const function_t& function) 
noexcept {
 
  331      *
this = delegate::remove(*
this, delegate(function));
 
  335    template<
typename fn_t>
 
  336    delegate& operator -=(fn_t function) 
noexcept {
 
  337      *
this = delegate::remove(*
this, delegate(function));
 
  343    static bool are_equals(
const std::function<result_t()>& fct1, 
const std::function<result_t()>& fct2) 
noexcept {
 
  344      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(*)()>());
 
  347    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 {
 
  348      auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item, function);});
 
  349      if (iterator != end) 
return iterator;
 
  369  template<
typename result_t, 
typename... arguments_t>
 
  370  class delegate<result_t(arguments_t...)> : 
public object, 
public xtd::iequatable<delegate<result_t(arguments_t...)>> {
 
  372      std::vector<std::function <result_t()>> no_arguments_functions;
 
  373      std::vector<std::function <result_t(arguments_t...)>> functions;
 
  380      std::any async_state() 
const noexcept override;
 
  382      bool completed_synchronously() 
const noexcept override;
 
  383      bool is_completed() 
const noexcept override;
 
  404    delegate(delegate&&) = 
default;
 
  405    delegate(
const delegate&) = 
default;
 
  406    delegate& operator =(
const delegate& delegate) = 
default;
 
  407    delegate(
const delegate<result_t()>& delegate) 
noexcept {data_->no_arguments_functions = delegate.functions();}
 
  415    delegate(
const no_arguments_function_t& function) 
noexcept {data_->no_arguments_functions.push_back(function);} 
 
  421    template<
typename object1_t, 
typename object2_t>
 
  422    delegate(
const object1_t& 
object, result_t(object2_t::*method)() const) noexcept {
 
  423      data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
 
  429    template<
typename object1_t, 
typename object2_t>
 
  430    delegate(
const object1_t& 
object, result_t(object2_t::*method)()) noexcept {
 
  431      data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
 
  436    template<
typename object1_t, 
typename object2_t, 
typename a1_t>
 
  437    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t) const) noexcept {
 
  438      data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1)));
 
  441    template<
typename object1_t, 
typename object2_t, 
typename a1_t>
 
  442    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t)) noexcept {
 
  443      data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1)));
 
  446    template<
typename object1_t, 
typename object2_t, 
typename a1_t, 
typename a2_t>
 
  447    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t) const) noexcept {
 
  448      data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2)));
 
  451    template<
typename object1_t, 
typename object2_t, 
typename a1_t, 
typename a2_t>
 
  452    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t)) noexcept {
 
  453      data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2)));
 
  456    template<
typename object1_t, 
typename object2_t, 
typename a1_t, 
typename a2_t, 
typename a3_t>
 
  457    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t) const) noexcept {
 
  458      data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
 
  461    template<
typename object1_t, 
typename object2_t, 
typename a1_t, 
typename a2_t, 
typename a3_t>
 
  462    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t)) noexcept {
 
  463      data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
 
  466    template<
typename object1_t, 
typename object2_t, 
typename a1_t, 
typename a2_t, 
typename a3_t, 
typename a4_t>
 
  467    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t) const) {
 
  468      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)));
 
  471    template<
typename object1_t, 
typename object2_t, 
typename a1_t, 
typename a2_t, 
typename a3_t, 
typename a4_t>
 
  472    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t)) noexcept {
 
  473      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)));
 
  476    template<
typename object1_t, 
typename object2_t, 
typename a1_t, 
typename a2_t, 
typename a3_t, 
typename a4_t, 
typename A5>
 
  477    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5) const) noexcept {
 
  478      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)));
 
  481    template<
typename object1_t, 
typename object2_t, 
typename a1_t, 
typename a2_t, 
typename a3_t, 
typename a4_t, 
typename A5>
 
  482    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5)) {
 
  483      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)));
 
  486    template<
typename object1_t, 
typename object2_t, 
typename a1_t, 
typename a2_t, 
typename a3_t, 
typename a4_t, 
typename A5, 
typename a6_t>
 
  487    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t) const) noexcept {
 
  488      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)));
 
  491    template<
typename object1_t, 
typename object2_t, 
typename a1_t, 
typename a2_t, 
typename a3_t, 
typename a4_t, 
typename A5, 
typename a6_t>
 
  492    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t)) noexcept {
 
  493      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)));
 
  496    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>
 
  497    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 {
 
  498      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)));
 
  501    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>
 
  502    delegate(
const object1_t& 
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t)) noexcept {
 
  503      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)));
 
  506    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>
 
  507    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 {
 
  508      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)));
 
  511    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>
 
  512    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 {
 
  513      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)));
 
  516    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>
 
  517    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 {
 
  518      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)));
 
  521    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>
 
  522    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 {
 
  523      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)));
 
  526    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>
 
  527    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 {
 
  528      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)));
 
  531    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>
 
  532    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 {
 
  533      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)));
 
  546    const std::vector<function_t>& 
functions()
 const {
return data_->functions;}
 
  550    bool is_empty() const noexcept {
return data_->functions.size() == 0 && data_->no_arguments_functions.size() == 0;}
 
  554    size_t size() const noexcept {
return data_->functions.size() + data_->no_arguments_functions.size();}
 
  598    result_t 
invoke(arguments_t... arguments)
 const {
return operator()(arguments...);}
 
  600    using object::equals;
 
  604    bool equals(
const delegate& delegate) 
const noexcept override {
 
  605      if (data_->functions.size() != delegate.data_->functions.size() || data_->no_arguments_functions.size() != delegate.data_->no_arguments_functions.size())
 
  608      for (
size_t i = 0; 
i < data_->no_arguments_functions.size(); 
i++)
 
  609        if (!are_equals(data_->no_arguments_functions[
i], delegate.data_->no_arguments_functions[
i]))
 
  612      for (
size_t i = 0; 
i < data_->functions.size(); 
i++)
 
  613        if (!are_equals(data_->functions[
i], delegate.data_->functions[
i]))
 
  628    static delegate 
combine(
const std::vector<delegate>& delegates) 
noexcept {
 
  630      for (
const delegate& delegate : delegates) {
 
  632          result.data_->no_arguments_functions.push_back(function);
 
  633        for (
const function_t& function : delegate.data_->functions)
 
  634          result.data_->functions.push_back(function);
 
  644    static delegate 
combine(
const delegate& a, 
const delegate& b) 
noexcept {
 
  647        result.data_->no_arguments_functions.push_back(function);
 
  648      for (
const function_t& function : 
b.data_->functions)
 
  649        result.data_->functions.push_back(function);
 
  658    static delegate 
remove(
const delegate& source, 
const delegate& value) 
noexcept {
 
  659      delegate result = source;
 
  660      std::for_each(value.data_->no_arguments_functions.begin(), value.data_->no_arguments_functions.end(), [&](
auto no_arguments_function) {
 
  661        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);});
 
  662        if (iterator != result.data_->no_arguments_functions.rend()) result.data_->no_arguments_functions.erase((iterator + 1).base());
 
  665      std::for_each(value.data_->functions.begin(), value.data_->functions.end(), [&](
auto function) {
 
  666        auto iterator = std::find_if(result.data_->functions.rbegin(), result.data_->functions.rend(), [&](auto item) {return are_equals(item, function);});
 
  667        if (iterator != result.data_->functions.rend()) result.data_->functions.erase((iterator + 1).base());
 
  677    static delegate 
remove_all(
const delegate& source, 
const delegate& value) 
noexcept {
 
  678      delegate result = source;
 
  680        if (find(result.data_->no_arguments_functions.begin(), result.data_->no_arguments_functions.end(), function) != result.data_->no_arguments_functions.end()) {
 
  681          for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->no_arguments_functions.rbegin(); iterator != result.data_->no_arguments_functions.rend(); ++iterator) {
 
  682            if (are_equals(*iterator, function))
 
  683              result.data_->no_arguments_functions.erase((iterator + 1).base());
 
  688      for (
const function_t& function : value.data_->functions) {
 
  689        if (find(result.data_->functions.begin(), result.data_->functions.end(), function) != result.data_->functions.end()) {
 
  690          for (
typename std::vector<function_t>::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
 
  691            if (are_equals(*iterator, function))
 
  692              result.data_->functions.erase((iterator + 1).base());
 
  707      if (data_->no_arguments_functions.size() == 0 && data_->functions.size() == 0) 
return result_t();
 
  709      if (data_->no_arguments_functions.size()) {
 
  710        for (
size_t i = 0; 
i < data_->no_arguments_functions.size() - (data_->functions.size() == 0 ? 1 : 0); 
i++) {
 
  712          data_->no_arguments_functions[
i]();
 
  715        if (data_->functions.size() == 0) {
 
  717          return data_->no_arguments_functions.back()();
 
  721      for (
size_t i = 0; 
i < data_->functions.size() - 1; 
i++) {
 
  723        data_->functions[
i](arguments...);
 
  726      return data_->functions.back()(arguments...);
 
  731    template<
typename type_t>
 
  732    delegate& operator =(
const type_t& function) 
noexcept {
 
  733      data_->no_arguments_functions.clear();
 
  734      data_->functions.clear();
 
  735      data_->functions.push_back(function_t(function));
 
  739    delegate& operator =(
const function_t& function) 
noexcept {
 
  740      data_->no_arguments_functions.clear();
 
  741      data_->functions.clear();
 
  742      data_->functions.push_back(function);
 
  746    delegate& operator =(
const no_arguments_function_t& function) 
noexcept {
 
  747      data_->no_arguments_functions.clear();
 
  748      data_->functions.clear();
 
  749      data_->no_arguments_functions.push_back(function);
 
  753    delegate operator +(
const delegate& other) 
noexcept {
 
  754      delegate result = *
this;
 
  759    delegate operator +(
const no_arguments_function_t& function) 
noexcept {
 
  760      delegate result = *
this;
 
  765    delegate operator +(
const function_t& function) 
noexcept {
 
  766      delegate result = *
this;
 
  771    template<
typename fn_t>
 
  772    delegate operator +(fn_t function) 
noexcept {
 
  773      delegate result = *
this;
 
  778    delegate& operator +=(
const delegate& delegate) 
noexcept {
 
  779      *
this = delegate::combine(*
this, delegate);
 
  783    delegate& operator +=(
const no_arguments_function_t& function) 
noexcept {
 
  784      *
this = delegate::combine(*
this, delegate(function));
 
  788    delegate& operator +=(
const function_t& function) 
noexcept {
 
  789      *
this = delegate::combine(*
this, delegate(function));
 
  793    template<
typename fn_t>
 
  794    delegate& operator +=(fn_t function) 
noexcept {
 
  795      *
this = delegate::combine(*
this, delegate(function));
 
  799    delegate operator -(
const delegate& other) 
noexcept {
 
  800      delegate result = *
this;
 
  805    delegate operator -(
const no_arguments_function_t& function) 
noexcept {
 
  806      delegate result = *
this;
 
  811    delegate operator -(
const function_t& function) 
noexcept {
 
  812      delegate result = *
this;
 
  817    template<
typename fn_t>
 
  818    delegate operator -(fn_t function) 
noexcept {
 
  819      delegate result = *
this;
 
  824    delegate& operator -=(
const delegate& delegate) 
noexcept {
 
  825      *
this = delegate::remove(*
this, delegate);
 
  829    delegate& operator -=(
const no_arguments_function_t& function) 
noexcept {
 
  830      *
this = delegate::remove(*
this, delegate(function));
 
  834    delegate& operator -=(
const function_t& function) 
noexcept {
 
  835      *
this = delegate::remove(*
this, delegate(function));
 
  839    template<
typename fn_t>
 
  840    delegate& operator -=(fn_t function) 
noexcept {
 
  841      *
this = delegate::remove(*
this, delegate(function));
 
  847    static bool are_equals(
const std::function<result_t(arguments_t...)>& fct1, 
const std::function<result_t(arguments_t...)>& fct2) 
noexcept {
 
  848      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...)>());
 
  851    static bool are_equals(
const std::function<result_t()>& fct1, 
const std::function<result_t()>& fct2) 
noexcept {
 
  852      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(*)()>());
 
  855    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 {
 
  856      auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item, function);});
 
  857      if (iterator != end) 
return iterator;
 
  861    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 {
 
  862      auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item, function);});
 
  863      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.
 
The exception that is thrown when one of the arguments provided to a method is null.
Definition argument_null_exception.hpp:23
 
bool equals(const delegate &delegate) const noexcept override
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.hpp:172
 
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:104
 
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:232
 
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:97
 
void clear()
Clear delegates array.
Definition delegate.hpp:129
 
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:192
 
bool is_empty() const noexcept
Return if the delegate is empty.
Definition delegate.hpp:118
 
size_t size() const noexcept
Return the size of invocation list.
Definition delegate.hpp:122
 
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:91
 
const std::vector< function_t > & functions() const
Gets the delegates array.
Definition delegate.hpp:114
 
std::function< result_t()> function_t
function_t pointer type
Definition delegate.hpp:75
 
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...
 
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition delegate.hpp:206
 
result_t invoke() const
invokes the method represented by the current delegate.
Definition delegate.hpp:166
 
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:218
 
result_t operator()() const
invokes the method represented by the current delegate.
Definition delegate.hpp:252
 
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:393
 
const std::vector< function_t > & functions() const
Gets the delegates array.
Definition delegate.hpp:546
 
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:598
 
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:628
 
delegate()=default
Initializes an empty delegate.
 
bool equals(const delegate &delegate) const noexcept override
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.hpp:604
 
const std::vector< no_arguments_function_t > & no_arguments_functions() const
Gets the no arguments delegates array.
Definition delegate.hpp:542
 
std::function< result_t(arguments_t...)> function_t
function_t pointer type
Definition delegate.hpp:395
 
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:430
 
size_t size() const noexcept
Return the size of invocation list.
Definition delegate.hpp:554
 
result_t operator()(arguments_t... arguments) const
invokes the method represented by the current delegate.
Definition delegate.hpp:706
 
bool is_empty() const noexcept
Return if the delegate is empty.
Definition delegate.hpp:550
 
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:658
 
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition delegate.hpp:644
 
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:677
 
delegate(const function_t &function) noexcept
Initializes a delegate that invokes the specified instance method.
Definition delegate.hpp:412
 
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...
 
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:422
 
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:42
 
Encapsulates operating system specific objects that wait for exclusive access to shared resources.
Definition wait_handle.hpp:52
 
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
 
delegate< void(async_result ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition delegate.hpp:36
 
@ 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.