TermOx
link_lifetimes.hpp
1 #ifndef TERMOX_WIDGET_DETAIL_LINK_LIFETIMES_HPP
2 #define TERMOX_WIDGET_DETAIL_LINK_LIFETIMES_HPP
3 #include <utility>
4 
5 #include <signals_light/signal.hpp>
6 
7 #include <termox/widget/detail/memfn_signature.hpp>
8 
9 namespace ox::slot {
10 
12 
13 template <typename... Widgets,
14  typename F,
15  typename Signature = detail::Call_signature_t<F>>
16 [[nodiscard]] auto link_lifetimes(F&& method, Widgets&... widgets)
17  -> sl::Slot<Signature>
18 {
19  static_assert(sizeof...(widgets) > 0, "You must link at least 1 lifetime");
20  auto slot = sl::Slot<Signature>{std::forward<F>(method)};
21  (slot.track(widgets.lifetime), ...);
22  return slot;
23 }
24 
25 } // namespace ox::slot
26 #endif // TERMOX_WIDGET_DETAIL_LINK_LIFETIMES_HPP