10#define STLAB_SCOPE_HPP
33#include <stlab/config.hpp>
42STLAB_VERSION_NAMESPACE_BEGIN()
53template <
typename T,
typename Tuple,
size_t... S>
54auto scope_call(Tuple&& t, std::index_sequence<S...>) {
55 T scoped(std::forward<std::tuple_element_t<S, Tuple>>(std::get<S>(t))...);
59 constexpr size_t last_index = std::tuple_size_v<Tuple> - 1;
60 return std::forward<std::tuple_element_t<last_index, Tuple>>(std::get<last_index>(t))();
70template <
typename T,
typename... Args>
71inline auto scope(Args&&... args) {
72 return detail::scope_call<T>(std::forward_as_tuple(std::forward<Args>(args)...),
73 std::make_index_sequence<
sizeof...(args) - 1>());
78template <
typename T,
typename F>
79inline auto scope(std::mutex& m, F&& f) {
81 return std::forward<F>(f)();
88STLAB_VERSION_NAMESPACE_END()
auto scope(Args &&... args)
Scopes the lifetime of an instance of T. All but the last arguments construct T; the last argument is...
Definition scope.hpp:71
Definition reverse.hpp:28