@@ -239,6 +239,21 @@ namespace delegate
239
239
return *this ;
240
240
}
241
241
242
+ template <typename F> DelegatePImpl& operator =(F functional)
243
+ {
244
+ if (FUNC == kind)
245
+ {
246
+ this ->functional .~FunctionType ();
247
+ }
248
+ else if (FPA == kind)
249
+ {
250
+ obj.~A ();
251
+ }
252
+ kind = FUNC;
253
+ new (&this ->functional ) FunctionType (std::forward<F>(functional));
254
+ return *this ;
255
+ }
256
+
242
257
DelegatePImpl& IRAM_ATTR operator =(std::nullptr_t )
243
258
{
244
259
if (FUNC == kind)
@@ -421,10 +436,10 @@ namespace delegate
421
436
DelegatePImpl::fn = fn;
422
437
}
423
438
424
- template <typename F> DelegatePImpl (F fn )
439
+ template <typename F> DelegatePImpl (F functional )
425
440
{
426
441
kind = FP;
427
- DelegatePImpl:: fn = std::forward<F>(fn );
442
+ fn = std::forward<F>(functional );
428
443
}
429
444
430
445
DelegatePImpl& operator =(const DelegatePImpl& del)
@@ -484,6 +499,16 @@ namespace delegate
484
499
return *this ;
485
500
}
486
501
502
+ template <typename F> DelegatePImpl& operator =(F functional)
503
+ {
504
+ if (FPA == kind)
505
+ {
506
+ obj = {};
507
+ }
508
+ kind = FP;
509
+ fn = std::forward<F>(functional);
510
+ }
511
+
487
512
DelegatePImpl& IRAM_ATTR operator =(std::nullptr_t )
488
513
{
489
514
if (FPA == kind)
@@ -683,6 +708,17 @@ namespace delegate
683
708
return *this ;
684
709
}
685
710
711
+ template <typename F> DelegatePImpl& operator =(F functional)
712
+ {
713
+ if (FUNC == kind)
714
+ {
715
+ this ->functional .~FunctionType ();
716
+ }
717
+ kind = FUNC;
718
+ new (&this ->functional ) FunctionType (std::forward<F>(functional));
719
+ return *this ;
720
+ }
721
+
686
722
DelegatePImpl& IRAM_ATTR operator =(std::nullptr_t )
687
723
{
688
724
if (FUNC == kind)
@@ -823,6 +859,12 @@ namespace delegate
823
859
return *this ;
824
860
}
825
861
862
+ template <typename F> DelegatePImpl& operator =(F functional)
863
+ {
864
+ fn = std::forward<F>(functional);
865
+ return *this ;
866
+ }
867
+
826
868
DelegatePImpl& IRAM_ATTR operator =(std::nullptr_t )
827
869
{
828
870
fn = nullptr ;
@@ -1040,6 +1082,21 @@ namespace delegate
1040
1082
return *this ;
1041
1083
}
1042
1084
1085
+ template <typename F> DelegateImpl& operator =(F functional)
1086
+ {
1087
+ if (FUNC == kind)
1088
+ {
1089
+ this ->functional .~FunctionType ();
1090
+ }
1091
+ else if (FPA == kind)
1092
+ {
1093
+ obj.~A ();
1094
+ }
1095
+ kind = FUNC;
1096
+ new (&this ->functional ) FunctionType (std::forward<F>(functional));
1097
+ return *this ;
1098
+ }
1099
+
1043
1100
DelegateImpl& IRAM_ATTR operator =(std::nullptr_t )
1044
1101
{
1045
1102
if (FUNC == kind)
@@ -1284,6 +1341,17 @@ namespace delegate
1284
1341
return *this ;
1285
1342
}
1286
1343
1344
+ template <typename F> DelegateImpl& operator =(F functional)
1345
+ {
1346
+ if (FPA == kind)
1347
+ {
1348
+ obj.~A ();
1349
+ }
1350
+ kind = FP;
1351
+ fn = std::forward<F>(functional);
1352
+ return *this ;
1353
+ }
1354
+
1287
1355
DelegateImpl& IRAM_ATTR operator =(std::nullptr_t )
1288
1356
{
1289
1357
if (FPA == kind)
@@ -1482,6 +1550,17 @@ namespace delegate
1482
1550
return *this ;
1483
1551
}
1484
1552
1553
+ template <typename F> DelegateImpl& operator =(F functional)
1554
+ {
1555
+ if (FUNC == kind)
1556
+ {
1557
+ this ->functional .~FunctionType ();
1558
+ }
1559
+ kind = FUNC;
1560
+ new (&this ->functional ) FunctionType (std::forward<F>(functional));
1561
+ return *this ;
1562
+ }
1563
+
1485
1564
DelegateImpl& IRAM_ATTR operator =(std::nullptr_t )
1486
1565
{
1487
1566
if (FUNC == kind)
@@ -1622,6 +1701,12 @@ namespace delegate
1622
1701
return *this ;
1623
1702
}
1624
1703
1704
+ template <typename F> DelegateImpl& operator =(F functional)
1705
+ {
1706
+ fn = std::forward<F>(functional);
1707
+ return *this ;
1708
+ }
1709
+
1625
1710
DelegateImpl& IRAM_ATTR operator =(std::nullptr_t )
1626
1711
{
1627
1712
fn = nullptr ;
@@ -1691,7 +1776,7 @@ namespace delegate
1691
1776
1692
1777
Delegate (FunPtr fn) : detail::DelegatePImpl<A, R, P...>::DelegatePImpl(fn) {}
1693
1778
1694
- template <typename F> Delegate (F functional) : detail::DelegatePImpl<A, R, P...>::DelegatePImpl(functional) {}
1779
+ template <typename F> Delegate (F functional) : detail::DelegatePImpl<A, R, P...>::DelegatePImpl(std::forward<F>( functional) ) {}
1695
1780
1696
1781
Delegate& operator =(const Delegate& del) {
1697
1782
detail::DelegatePImpl<A, R, P...>::operator =(del);
@@ -1708,6 +1793,11 @@ namespace delegate
1708
1793
return *this ;
1709
1794
}
1710
1795
1796
+ template <typename F> Delegate& operator =(F functional) {
1797
+ detail::DelegatePImpl<A, R, P...>::operator =(std::forward<F>(functional));
1798
+ return *this ;
1799
+ }
1800
+
1711
1801
Delegate& IRAM_ATTR operator =(std::nullptr_t ) {
1712
1802
detail::DelegatePImpl<A, R, P...>::operator =(nullptr );
1713
1803
return *this ;
@@ -1770,7 +1860,7 @@ namespace delegate
1770
1860
1771
1861
Delegate (FunPtr fn) : detail::DelegatePImpl<A*, R, P...>::DelegatePImpl(fn) {}
1772
1862
1773
- template <typename F> Delegate (F functional) : detail::DelegatePImpl<A*, R, P...>::DelegatePImpl(functional) {}
1863
+ template <typename F> Delegate (F functional) : detail::DelegatePImpl<A*, R, P...>::DelegatePImpl(std::forward<F>( functional) ) {}
1774
1864
1775
1865
Delegate& operator =(const Delegate& del) {
1776
1866
detail::DelegatePImpl<A*, R, P...>::operator =(del);
@@ -1787,6 +1877,11 @@ namespace delegate
1787
1877
return *this ;
1788
1878
}
1789
1879
1880
+ template <typename F> Delegate& operator =(F functional) {
1881
+ detail::DelegatePImpl<A*, R, P...>::operator =(std::forward<F>(functional));
1882
+ return *this ;
1883
+ }
1884
+
1790
1885
Delegate& IRAM_ATTR operator =(std::nullptr_t ) {
1791
1886
detail::DelegatePImpl<A*, R, P...>::operator =(nullptr );
1792
1887
return *this ;
@@ -1826,7 +1921,7 @@ namespace delegate
1826
1921
1827
1922
Delegate (FunPtr fn) : detail::DelegatePImpl<void, R, P...>::DelegatePImpl(fn) {}
1828
1923
1829
- template <typename F> Delegate (F functional) : detail::DelegatePImpl<void, R, P...>::DelegatePImpl(functional) {}
1924
+ template <typename F> Delegate (F functional) : detail::DelegatePImpl<void, R, P...>::DelegatePImpl(std::forward<F>( functional) ) {}
1830
1925
1831
1926
Delegate& operator =(const Delegate& del) {
1832
1927
detail::DelegatePImpl<void , R, P...>::operator =(del);
@@ -1843,6 +1938,11 @@ namespace delegate
1843
1938
return *this ;
1844
1939
}
1845
1940
1941
+ template <typename F> Delegate& operator =(F functional) {
1942
+ detail::DelegatePImpl<void , R, P...>::operator =(std::forward<F>(functional));
1943
+ return *this ;
1944
+ }
1945
+
1846
1946
Delegate& IRAM_ATTR operator =(std::nullptr_t ) {
1847
1947
detail::DelegatePImpl<void , R, P...>::operator =(nullptr );
1848
1948
return *this ;
@@ -1887,7 +1987,7 @@ namespace delegate
1887
1987
1888
1988
Delegate (FunPtr fn) : detail::DelegateImpl<A, R>::DelegateImpl(fn) {}
1889
1989
1890
- template <typename F> Delegate (F functional) : detail::DelegateImpl<A, R>::DelegateImpl(functional) {}
1990
+ template <typename F> Delegate (F functional) : detail::DelegateImpl<A, R>::DelegateImpl(std::forward<F>( functional) ) {}
1891
1991
1892
1992
Delegate& operator =(const Delegate& del) {
1893
1993
detail::DelegateImpl<A, R>::operator =(del);
@@ -1904,6 +2004,11 @@ namespace delegate
1904
2004
return *this ;
1905
2005
}
1906
2006
2007
+ template <typename F> Delegate& operator =(F functional) {
2008
+ detail::DelegateImpl<A, R>::operator =(std::forward<F>(functional));
2009
+ return *this ;
2010
+ }
2011
+
1907
2012
Delegate& IRAM_ATTR operator =(std::nullptr_t ) {
1908
2013
detail::DelegateImpl<A, R>::operator =(nullptr );
1909
2014
return *this ;
@@ -1966,7 +2071,7 @@ namespace delegate
1966
2071
1967
2072
Delegate (FunPtr fn) : detail::DelegateImpl<A*, R>::DelegateImpl(fn) {}
1968
2073
1969
- template <typename F> Delegate (F functional) : detail::DelegateImpl<A*, R>::DelegateImpl(functional) {}
2074
+ template <typename F> Delegate (F functional) : detail::DelegateImpl<A*, R>::DelegateImpl(std::forward<F>( functional) ) {}
1970
2075
1971
2076
Delegate& operator =(const Delegate& del) {
1972
2077
detail::DelegateImpl<A*, R>::operator =(del);
@@ -1983,6 +2088,11 @@ namespace delegate
1983
2088
return *this ;
1984
2089
}
1985
2090
2091
+ template <typename F> Delegate& operator =(F functional) {
2092
+ detail::DelegateImpl<A*, R>::operator =(std::forward<F>(functional));
2093
+ return *this ;
2094
+ }
2095
+
1986
2096
Delegate& IRAM_ATTR operator =(std::nullptr_t ) {
1987
2097
detail::DelegateImpl<A*, R>::operator =(nullptr );
1988
2098
return *this ;
@@ -2022,7 +2132,7 @@ namespace delegate
2022
2132
2023
2133
Delegate (FunPtr fn) : detail::DelegateImpl<void, R>::DelegateImpl(fn) {}
2024
2134
2025
- template <typename F> Delegate (F functional) : detail::DelegateImpl<void, R>::DelegateImpl(functional) {}
2135
+ template <typename F> Delegate (F functional) : detail::DelegateImpl<void, R>::DelegateImpl(std::forward<F>( functional) ) {}
2026
2136
2027
2137
Delegate& operator =(const Delegate& del) {
2028
2138
detail::DelegateImpl<void , R>::operator =(del);
@@ -2039,6 +2149,11 @@ namespace delegate
2039
2149
return *this ;
2040
2150
}
2041
2151
2152
+ template <typename F> Delegate& operator =(F functional) {
2153
+ detail::DelegateImpl<void , R>::operator =(std::forward<F>(functional));
2154
+ return *this ;
2155
+ }
2156
+
2042
2157
Delegate& IRAM_ATTR operator =(std::nullptr_t ) {
2043
2158
detail::DelegateImpl<void , R>::operator =(nullptr );
2044
2159
return *this ;
@@ -2067,7 +2182,7 @@ template<typename A, typename R, typename... P> class Delegate<R(P...), A> : pub
2067
2182
2068
2183
Delegate (typename delegate::detail::Delegate<A, R, P...>::FunPtr fn) : delegate::detail::Delegate<A, R, P...>::Delegate(fn) {}
2069
2184
2070
- template <typename F> Delegate (F functional) : delegate::detail::Delegate<A, R, P...>::Delegate(functional) {}
2185
+ template <typename F> Delegate (F functional) : delegate::detail::Delegate<A, R, P...>::Delegate(std::forward<F>( functional) ) {}
2071
2186
2072
2187
Delegate& operator =(const Delegate& del) {
2073
2188
delegate::detail::Delegate<A, R, P...>::operator =(del);
@@ -2084,11 +2199,17 @@ template<typename A, typename R, typename... P> class Delegate<R(P...), A> : pub
2084
2199
return *this ;
2085
2200
}
2086
2201
2202
+ template <typename F> Delegate& operator =(F functional) {
2203
+ delegate::detail::Delegate<A, R, P...>::operator =(std::forward<F>(functional));
2204
+ return *this ;
2205
+ }
2206
+
2087
2207
Delegate& IRAM_ATTR operator =(std::nullptr_t ) {
2088
2208
delegate::detail::Delegate<A, R, P...>::operator =(nullptr );
2089
2209
return *this ;
2090
2210
}
2091
2211
};
2212
+
2092
2213
template <typename R, typename ... P> class Delegate <R(P...)> : public delegate::detail::Delegate<void , R, P...>
2093
2214
{
2094
2215
public:
@@ -2104,7 +2225,7 @@ template<typename R, typename... P> class Delegate<R(P...)> : public delegate::d
2104
2225
2105
2226
Delegate (typename delegate::detail::Delegate<void , R, P...>::FunPtr fn) : delegate::detail::Delegate<void, R, P...>::Delegate(fn) {}
2106
2227
2107
- template <typename F> Delegate (F functional) : delegate::detail::Delegate<void, R, P...>::Delegate(functional) {}
2228
+ template <typename F> Delegate (F functional) : delegate::detail::Delegate<void, R, P...>::Delegate(std::forward<F>( functional) ) {}
2108
2229
2109
2230
Delegate& operator =(const Delegate& del) {
2110
2231
delegate::detail::Delegate<void , R, P...>::operator =(del);
@@ -2121,6 +2242,11 @@ template<typename R, typename... P> class Delegate<R(P...)> : public delegate::d
2121
2242
return *this ;
2122
2243
}
2123
2244
2245
+ template <typename F> Delegate& operator =(F functional) {
2246
+ delegate::detail::Delegate<void , R, P...>::operator =(std::forward<F>(functional));
2247
+ return *this ;
2248
+ }
2249
+
2124
2250
Delegate& IRAM_ATTR operator =(std::nullptr_t ) {
2125
2251
delegate::detail::Delegate<void , R, P...>::operator =(nullptr );
2126
2252
return *this ;
0 commit comments