39 #ifndef CGU_CALLBACK_H
40 #define CGU_CALLBACK_H
500 #include <functional>
504 #include <type_traits>
608 template <
class... FreeArgs>
648 #ifdef CGU_USE_GLIB_MEMORY_SLICES_NO_COMPAT
731 return std::unique_ptr<
const CallbackArg<T...>>(cb);
750 template <
class... T>
752 return (f1.cb_s.get() == f2.cb_s.get());
760 template <
class... T>
778 template <
class... T>
780 return std::less<
const CallbackArg<T...>*>()(f1.cb_s.get(), f2.cb_s.get());
788 template <
class... T>
790 return (f1.cb_s.get() == f2.cb_s.get());
798 template <
class... T>
811 template <
class... T>
813 return std::less<
const CallbackArg<T...>*>()(f1.cb_s.get(), f2.cb_s.get());
822 #ifndef DOXYGEN_PARSING
827 template <
class... T>
828 struct hash<Cgu::Callback::FunctorArg<T...>> {
829 typedef std::size_t result_type;
831 result_type operator()(
const argument_type& f)
const {
838 template <
class... T>
839 struct hash<Cgu::Callback::SafeFunctorArg<T...>> {
840 typedef std::size_t result_type;
842 result_type operator()(
const argument_type& f)
const {
851 #endif // DOXYGEN_PARSING
914 template <
class... FreeArgs>
916 SharedPtr<
const CallbackArg<FreeArgs...>> cb_s;
939 if (cb_s.get()) cb_s->dispatch(args...);
971 friend
bool operator< <>(const
FunctorArg&, const FunctorArg&);
973 friend struct std::hash<FunctorArg>;
1038 template <
class... FreeArgs>
1039 class SafeFunctorArg {
1054 if (cb_s.get()) cb_s->dispatch(args...);
1086 friend
bool operator< <>(const
SafeFunctorArg&, const SafeFunctorArg&);
1088 friend struct std::hash<SafeFunctorArg>;
1170 template<
class... T>
1210 template<
class... T>
1217 template <
class T,
class... FreeArgs>
1226 (obj->*func)(free_args...);
1231 template <
bool unref,
class T,
class BoundArg,
class... FreeArgs>
1234 typedef void (T::*
MemFunc)(BoundArg, FreeArgs...);
1241 (obj->*func)(arg, free_args...);
1243 template <
class Arg>
1245 Arg&& arg_): obj(&obj_), func(func_), arg(std::forward<Arg>(arg_)) {}
1248 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1251 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, FreeArgs...);
1259 (obj->*func)(arg1, arg2, free_args...);
1261 template <
class Arg1,
class Arg2>
1264 Arg2&& arg2_): obj(&obj_), func(func_),
1265 arg1(std::forward<Arg1>(arg1_)),
1266 arg2(std::forward<Arg2>(arg2_)) {}
1269 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1272 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...);
1281 (obj->*func)(arg1, arg2, arg3, free_args...);
1283 template <
class Arg1,
class Arg2,
class Arg3>
1288 obj(&obj_), func(func_),
1289 arg1(std::forward<Arg1>(arg1_)),
1290 arg2(std::forward<Arg2>(arg2_)),
1291 arg3(std::forward<Arg3>(arg3_)) {}
1294 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1295 class BoundArg4,
class... FreeArgs>
1298 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, BoundArg4, FreeArgs...);
1308 (obj->*func)(arg1, arg2, arg3, arg4, free_args...);
1310 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4>
1316 obj(&obj_), func(func_),
1317 arg1(std::forward<Arg1>(arg1_)),
1318 arg2(std::forward<Arg2>(arg2_)),
1319 arg3(std::forward<Arg3>(arg3_)),
1320 arg4(std::forward<Arg4>(arg4_)) {}
1323 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1324 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1327 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3,
1328 BoundArg4, BoundArg5, FreeArgs...);
1339 (obj->*func)(arg1, arg2, arg3, arg4, arg5, free_args...);
1341 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
1348 obj(&obj_), func(func_),
1349 arg1(std::forward<Arg1>(arg1_)),
1350 arg2(std::forward<Arg2>(arg2_)),
1351 arg3(std::forward<Arg3>(arg3_)),
1352 arg4(std::forward<Arg4>(arg4_)),
1353 arg5(std::forward<Arg5>(arg5_)) {}
1358 template <
class T,
class... FreeArgs>
1367 (obj->*func)(free_args...);
1372 template <
bool unref,
class T,
class BoundArg,
class... FreeArgs>
1375 typedef void (T::*
MemFunc)(BoundArg, FreeArgs...)
const;
1382 (obj->*func)(arg, free_args...);
1384 template <
class Arg>
1386 Arg&& arg_): obj(&obj_), func(func_), arg(std::forward<Arg>(arg_)) {}
1389 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1392 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, FreeArgs...)
const;
1400 (obj->*func)(arg1, arg2, free_args...);
1402 template <
class Arg1,
class Arg2>
1405 Arg2&& arg2_): obj(&obj_), func(func_),
1406 arg1(std::forward<Arg1>(arg1_)),
1407 arg2(std::forward<Arg2>(arg2_)) {}
1410 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1413 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const;
1422 (obj->*func)(arg1, arg2, arg3, free_args...);
1424 template <
class Arg1,
class Arg2,
class Arg3>
1429 obj(&obj_), func(func_),
1430 arg1(std::forward<Arg1>(arg1_)),
1431 arg2(std::forward<Arg2>(arg2_)),
1432 arg3(std::forward<Arg3>(arg3_)) {}
1435 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1436 class BoundArg4,
class... FreeArgs>
1439 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, BoundArg4, FreeArgs...)
const;
1449 (obj->*func)(arg1, arg2, arg3, arg4, free_args...);
1451 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4>
1457 obj(&obj_), func(func_),
1458 arg1(std::forward<Arg1>(arg1_)),
1459 arg2(std::forward<Arg2>(arg2_)),
1460 arg3(std::forward<Arg3>(arg3_)),
1461 arg4(std::forward<Arg4>(arg4_)) {}
1464 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1465 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1468 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3,
1469 BoundArg4, BoundArg5, FreeArgs...)
const;
1480 (obj->*func)(arg1, arg2, arg3, arg4, arg5, free_args...);
1482 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
1489 obj(&obj_), func(func_),
1490 arg1(std::forward<Arg1>(arg1_)),
1491 arg2(std::forward<Arg2>(arg2_)),
1492 arg3(std::forward<Arg3>(arg3_)),
1493 arg4(std::forward<Arg4>(arg4_)),
1494 arg5(std::forward<Arg5>(arg5_)) {}
1499 template <
class... FreeArgs>
1512 template <
bool unref,
class BoundArg,
class... FreeArgs>
1515 typedef void (*
Func)(BoundArg, FreeArgs...);
1521 func(arg, free_args...);
1523 template <
class Arg>
1527 template <
bool unref,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1530 typedef void (*
Func)(BoundArg1, BoundArg2, FreeArgs...);
1537 func(arg1, arg2, free_args...);
1539 template <
class Arg1,
class Arg2>
1541 Arg2&& arg2_): func(func_),
1542 arg1(std::forward<Arg1>(arg1_)),
1543 arg2(std::forward<Arg2>(arg2_)) {}
1546 template <
bool unref,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1549 typedef void (*
Func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...);
1557 func(arg1, arg2, arg3, free_args...);
1559 template <
class Arg1,
class Arg2,
class Arg3>
1565 arg1(std::forward<Arg1>(arg1_)),
1566 arg2(std::forward<Arg2>(arg2_)),
1567 arg3(std::forward<Arg3>(arg3_)) {}
1570 template <
bool unref,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1571 class BoundArg4,
class... FreeArgs>
1574 typedef void (*
Func)(BoundArg1, BoundArg2, BoundArg3, BoundArg4, FreeArgs...);
1583 func(arg1, arg2, arg3, arg4, free_args...);
1585 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4>
1592 arg1(std::forward<Arg1>(arg1_)),
1593 arg2(std::forward<Arg2>(arg2_)),
1594 arg3(std::forward<Arg3>(arg3_)),
1595 arg4(std::forward<Arg4>(arg4_)) {}
1598 template <
bool unref,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1599 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1602 typedef void (*
Func)(BoundArg1, BoundArg2, BoundArg3,
1603 BoundArg4, BoundArg5, FreeArgs...);
1613 func(arg1, arg2, arg3, arg4, arg5, free_args...);
1615 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
1623 arg1(std::forward<Arg1>(arg1_)),
1624 arg2(std::forward<Arg2>(arg2_)),
1625 arg3(std::forward<Arg3>(arg3_)),
1626 arg4(std::forward<Arg4>(arg4_)),
1627 arg5(std::forward<Arg5>(arg5_)) {}
1631 template <
class Lambda,
class... FreeArgs>
1656 template <
class T,
class... FreeArgs>
1658 void (T::*func)(FreeArgs...)) {
1659 return new Callback0<T, FreeArgs...>{t, func};
1674 template <
class T,
class... FreeArgs>
1676 void (T::*func)(FreeArgs...)) {
1677 return new Callback0<T, FreeArgs...>{t, func};
1691 template <
class T,
class BoundArg,
class... FreeArgs>
1693 void (T::*func)(BoundArg, FreeArgs...),
1695 return new Callback1<
false, T, BoundArg, FreeArgs...>{t, func, arg};
1715 template <
class T,
class BoundArg,
class Arg,
class... FreeArgs>
1717 void (T::*func)(BoundArg, FreeArgs...),
1719 return new Callback1<
true, T, BoundArg, FreeArgs...>{t, func, std::forward<Arg>(arg)};
1733 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1735 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...),
1738 return new Callback2<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
1758 template <
class T,
class BoundArg1,
class BoundArg2,
1759 class Arg1,
class Arg2,
class... FreeArgs>
1761 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...),
1764 return new Callback2<
true, T, BoundArg1, BoundArg2, FreeArgs...>{t, func,
1765 std::forward<Arg1>(arg1),
1766 std::forward<Arg2>(arg2)};
1780 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1782 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
1786 return new Callback3<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
1806 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1807 class Arg1,
class Arg2,
class Arg3,
class... FreeArgs>
1809 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
1813 return new Callback3<
true, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func,
1814 std::forward<Arg1>(arg1),
1815 std::forward<Arg2>(arg2),
1816 std::forward<Arg3>(arg3)};
1830 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1831 class BoundArg4,
class... FreeArgs>
1833 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1834 BoundArg4, FreeArgs...),
1839 return new Callback4<
false, T, BoundArg1, BoundArg2, BoundArg3,
1840 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
1860 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
1861 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class... FreeArgs>
1863 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1864 BoundArg4, FreeArgs...),
1869 return new Callback4<
true, T, BoundArg1, BoundArg2, BoundArg3,
1870 BoundArg4, FreeArgs...>{t, func,
1871 std::forward<Arg1>(arg1),
1872 std::forward<Arg2>(arg2),
1873 std::forward<Arg3>(arg3),
1874 std::forward<Arg4>(arg4)};
1888 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1889 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1891 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1892 BoundArg4, BoundArg5, FreeArgs...),
1898 return new Callback5<
false, T, BoundArg1, BoundArg2, BoundArg3,
1899 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
1919 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
class BoundArg5,
1920 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class... FreeArgs>
1922 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1923 BoundArg4, BoundArg5, FreeArgs...),
1929 return new Callback5<
true, T, BoundArg1, BoundArg2, BoundArg3,
1930 BoundArg4, BoundArg5, FreeArgs...>{t, func,
1931 std::forward<Arg1>(arg1),
1932 std::forward<Arg2>(arg2),
1933 std::forward<Arg3>(arg3),
1934 std::forward<Arg4>(arg4),
1935 std::forward<Arg5>(arg5)};
1949 template <
class T,
class... FreeArgs>
1951 void (T::*func)(FreeArgs...)
const) {
1967 template <
class T,
class... FreeArgs>
1969 void (T::*func)(FreeArgs...)
const) {
1984 template <
class T,
class BoundArg,
class... FreeArgs>
1986 void (T::*func)(BoundArg, FreeArgs...)
const,
1988 return new Callback1_const<
false, T, BoundArg, FreeArgs...>{t, func, arg};
2008 template <
class T,
class BoundArg,
class Arg,
class... FreeArgs>
2010 void (T::*func)(BoundArg, FreeArgs...)
const,
2012 return new Callback1_const<
true, T, BoundArg, FreeArgs...>{t, func, std::forward<Arg>(arg)};
2026 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2028 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...)
const,
2031 return new Callback2_const<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
2051 template <
class T,
class BoundArg1,
class BoundArg2,
2052 class Arg1,
class Arg2,
class... FreeArgs>
2054 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...)
const,
2057 return new Callback2_const<
true, T, BoundArg1, BoundArg2, FreeArgs...>{t, func,
2058 std::forward<Arg1>(arg1),
2059 std::forward<Arg2>(arg2)};
2073 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2075 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const,
2079 return new Callback3_const<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
2099 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2100 class Arg1,
class Arg2,
class Arg3,
class... FreeArgs>
2102 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const,
2106 return new Callback3_const<
true, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func,
2107 std::forward<Arg1>(arg1),
2108 std::forward<Arg2>(arg2),
2109 std::forward<Arg3>(arg3)};
2123 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2124 class BoundArg4,
class... FreeArgs>
2126 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2127 BoundArg4, FreeArgs...)
const,
2133 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
2153 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
2154 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class... FreeArgs>
2156 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2157 BoundArg4, FreeArgs...)
const,
2163 BoundArg4, FreeArgs...>{t, func,
2164 std::forward<Arg1>(arg1),
2165 std::forward<Arg2>(arg2),
2166 std::forward<Arg3>(arg3),
2167 std::forward<Arg4>(arg4)};
2181 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2182 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2184 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2185 BoundArg4, BoundArg5, FreeArgs...)
const,
2192 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
2212 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
class BoundArg5,
2213 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class... FreeArgs>
2215 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2216 BoundArg4, BoundArg5, FreeArgs...)
const,
2223 BoundArg4, BoundArg5, FreeArgs...>{t, func,
2224 std::forward<Arg1>(arg1),
2225 std::forward<Arg2>(arg2),
2226 std::forward<Arg3>(arg3),
2227 std::forward<Arg4>(arg4),
2228 std::forward<Arg5>(arg5)};
2242 template <
class... FreeArgs>
2259 template <
class... FreeArgs>
2275 template <
class BoundArg,
class... FreeArgs>
2298 template <
class BoundArg,
class Arg,
class... FreeArgs>
2301 return new Callback1_static<
true, BoundArg, FreeArgs...>{func, std::forward<Arg>(arg)};
2315 template <
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2319 return new Callback2_static<
false, BoundArg1, BoundArg2, FreeArgs...>{func, arg1, arg2};
2339 template <
class BoundArg1,
class BoundArg2,
class Arg1,
class Arg2,
class... FreeArgs>
2344 std::forward<Arg1>(arg1),
2345 std::forward<Arg2>(arg2)};
2359 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2360 CallbackArg<FreeArgs...>*
make(
void (*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
2364 return new Callback3_static<
false, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{func, arg1, arg2, arg3};
2384 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2385 class Arg1,
class Arg2,
class Arg3,
class... FreeArgs>
2390 return new Callback3_static<
true, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{func,
2391 std::forward<Arg1>(arg1),
2392 std::forward<Arg2>(arg2),
2393 std::forward<Arg3>(arg3)};
2407 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2408 class BoundArg4,
class... FreeArgs>
2410 BoundArg4, FreeArgs...),
2416 BoundArg4, FreeArgs...>{func, arg1, arg2, arg3, arg4};
2436 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
2437 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class... FreeArgs>
2439 BoundArg4, FreeArgs...),
2445 BoundArg4, FreeArgs...>{func,
2446 std::forward<Arg1>(arg1),
2447 std::forward<Arg2>(arg2),
2448 std::forward<Arg3>(arg3),
2449 std::forward<Arg4>(arg4)};
2463 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2464 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2466 BoundArg4, BoundArg5, FreeArgs...),
2473 BoundArg4, BoundArg5, FreeArgs...>{func, arg1, arg2, arg3, arg4, arg5};
2493 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
class BoundArg5,
2494 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class... FreeArgs>
2496 BoundArg4, BoundArg5, FreeArgs...),
2503 BoundArg4, BoundArg5, FreeArgs...>{func,
2504 std::forward<Arg1>(arg1),
2505 std::forward<Arg2>(arg2),
2506 std::forward<Arg3>(arg3),
2507 std::forward<Arg4>(arg4),
2508 std::forward<Arg5>(arg5)};
2525 template <
class... FreeArgs>
2527 typedef std::function<void(FreeArgs...)> LType;
2545 template <
class... FreeArgs>
2547 typedef std::function<void(FreeArgs...)> LType;
2563 template <
class... FreeArgs>
2565 typedef std::function<void(FreeArgs...)> LType;
2583 template <
class... FreeArgs>
2585 typedef std::function<void(FreeArgs...)> LType;
2629 template <
class... FreeArgs,
class Lambda>
2631 typedef typename std::remove_const<typename std::remove_reference<Lambda>::type>::type LType;
2632 return new Callback_lambda<LType, FreeArgs...>{std::forward<Lambda>(l)};
2635 #ifndef DOXYGEN_PARSING
2641 template <
class T,
class... FreeArgs>
2643 void (T::*func)(FreeArgs...)) {
2644 return new Callback0<T, FreeArgs...>{t, func};
2646 template <
class T,
class BoundArg,
class... FreeArgs>
2648 void (T::*func)(BoundArg, FreeArgs...),
2649 const BoundArg& arg) {
2650 return new Callback1<
false, T, BoundArg, FreeArgs...>{t, func, arg};
2652 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2654 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...),
2655 const BoundArg1& arg1,
2656 const BoundArg2& arg2) {
2657 return new Callback2<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
2659 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2661 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
2662 const BoundArg1& arg1,
2663 const BoundArg2& arg2,
2664 const BoundArg3& arg3) {
2665 return new Callback3<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
2667 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2668 class BoundArg4,
class... FreeArgs>
2670 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2671 BoundArg4, FreeArgs...),
2672 const BoundArg1& arg1,
2673 const BoundArg2& arg2,
2674 const BoundArg3& arg3,
2675 const BoundArg4& arg4) {
2676 return new Callback4<
false, T, BoundArg1, BoundArg2, BoundArg3,
2677 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
2679 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2680 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2682 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2683 BoundArg4, BoundArg5, FreeArgs...),
2684 const BoundArg1& arg1,
2685 const BoundArg2& arg2,
2686 const BoundArg3& arg3,
2687 const BoundArg4& arg4,
2688 const BoundArg5& arg5) {
2689 return new Callback5<
false, T, BoundArg1, BoundArg2, BoundArg3,
2690 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
2692 template <
class T,
class... FreeArgs>
2694 void (T::*func)(FreeArgs...)
const) {
2697 template <
class T,
class BoundArg,
class... FreeArgs>
2699 void (T::*func)(BoundArg, FreeArgs...)
const,
2700 const BoundArg& arg) {
2701 return new Callback1_const<
false, T, BoundArg, FreeArgs...>{t, func, arg};
2703 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2705 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...)
const,
2706 const BoundArg1& arg1,
2707 const BoundArg2& arg2) {
2708 return new Callback2_const<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
2710 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2712 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const,
2713 const BoundArg1& arg1,
2714 const BoundArg2& arg2,
2715 const BoundArg3& arg3) {
2716 return new Callback3_const<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
2718 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2719 class BoundArg4,
class... FreeArgs>
2721 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2722 BoundArg4, FreeArgs...)
const,
2723 const BoundArg1& arg1,
2724 const BoundArg2& arg2,
2725 const BoundArg3& arg3,
2726 const BoundArg4& arg4) {
2728 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
2730 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2731 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2733 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2734 BoundArg4, BoundArg5, FreeArgs...)
const,
2735 const BoundArg1& arg1,
2736 const BoundArg2& arg2,
2737 const BoundArg3& arg3,
2738 const BoundArg4& arg4,
2739 const BoundArg5& arg5) {
2741 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
2743 template <
class... FreeArgs>
2744 CallbackArg<FreeArgs...>* make_val(
void (*func)(FreeArgs...)) {
2747 template <
class BoundArg,
class... FreeArgs>
2748 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg, FreeArgs...),
2749 const BoundArg& arg) {
2752 template <
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2753 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, FreeArgs...),
2754 const BoundArg1& arg1,
2755 const BoundArg2& arg2) {
2756 return new Callback2_static<
false, BoundArg1, BoundArg2, FreeArgs...>{func, arg1, arg2};
2758 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2759 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
2760 const BoundArg1& arg1,
2761 const BoundArg2& arg2,
2762 const BoundArg3& arg3) {
2763 return new Callback3_static<
false, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{func, arg1, arg2, arg3};
2765 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2766 class BoundArg4,
class... FreeArgs>
2767 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, BoundArg3,
2768 BoundArg4, FreeArgs...),
2769 const BoundArg1& arg1,
2770 const BoundArg2& arg2,
2771 const BoundArg3& arg3,
2772 const BoundArg4& arg4) {
2774 BoundArg4, FreeArgs...>{func, arg1, arg2, arg3, arg4};
2776 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2777 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2778 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, BoundArg3,
2779 BoundArg4, BoundArg5, FreeArgs...),
2780 const BoundArg1& arg1,
2781 const BoundArg2& arg2,
2782 const BoundArg3& arg3,
2783 const BoundArg4& arg4,
2784 const BoundArg5& arg5) {
2786 BoundArg4, BoundArg5, FreeArgs...>{func, arg1, arg2, arg3, arg4, arg5};
2788 template <
class... FreeArgs>
2789 CallbackArg<FreeArgs...>* make_val(
const std::function<
void(FreeArgs...)>& f) {
2790 typedef std::function<void(FreeArgs...)> LType;
2793 template <
class... FreeArgs>
2794 CallbackArg<FreeArgs...>* make_val(std::function<
void(FreeArgs...)>&& f) {
2795 typedef std::function<void(FreeArgs...)> LType;
2798 #endif // DOXYGEN_PARSING
2830 void post(
const Callback* cb, gint priority = G_PRIORITY_DEFAULT_IDLE,
2831 GMainContext* context = 0);
2882 gint priority = G_PRIORITY_DEFAULT_IDLE, GMainContext* context = 0);
2927 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
2929 void post(F&& func, gint priority = G_PRIORITY_DEFAULT_IDLE,
2930 GMainContext* context = 0) {
2931 post(lambda<>(std::forward<F>(func)), priority, context);
2992 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
2995 gint priority = G_PRIORITY_DEFAULT_IDLE, GMainContext* context = 0) {
2996 post(lambda<>(std::forward<F>(func)), r, priority, context);