24template <
typename T,
typename =
void>
25struct is_noarg_callable_t :
public std::false_type
31struct is_noarg_callable_t<T, decltype(std::declval<T&&>()())> :
public std::true_type
38struct returns_void_t :
public std::is_same<void, decltype(std::declval<T&&>()())>
45struct is_nothrow_invocable_if_required_t :
public std::true_type
50template <
typename A,
typename B,
typename... C>
51struct and_t :
public and_t<A, and_t<B, C...>>
56template <
typename A,
typename B>
57struct and_t<A, B> :
public std::conditional<A::value, B, A>::type
64struct is_proper_sg_callback_t :
public and_t<
65 is_noarg_callable_t<T>,
67 is_nothrow_invocable_if_required_t<T>,
68 std::is_nothrow_destructible<T>>
76 typename =
typename std::enable_if<is_proper_sg_callback_t<Callback>::value>::type>
107template <
typename Callback>
109 std::is_nothrow_constructible<Callback, Callback&&>::value);
117template <
typename Callback>
118class scope_guard<Callback> final
121 typedef Callback callback_type;
123 scope_guard(scope_guard&& other)
noexcept(
124 std::is_nothrow_constructible<Callback, Callback&&>::value);
126 ~scope_guard()
noexcept;
128 void dismiss()
noexcept;
131 scope_guard() =
delete;
132 scope_guard(
const scope_guard&) =
delete;
133 scope_guard& operator=(
const scope_guard&) =
delete;
134 scope_guard& operator=(scope_guard&&) =
delete;
138 explicit scope_guard(Callback&& callback)
noexcept(
139 std::is_nothrow_constructible<Callback, Callback&&>::value);
142 friend scope_guard<Callback> make_scope_guard<Callback>(Callback&&)
noexcept(
143 std::is_nothrow_constructible<Callback, Callback&&>::value);
159template <
typename Callback>
160sg_detail::scope_guard<Callback>::scope_guard(Callback&& callback)
noexcept(
161 std::is_nothrow_constructible<Callback, Callback&&>::value)
165 : m_callback(std::forward<Callback>(callback))
171template <
typename Callback>
172sg_detail::scope_guard<Callback>::~scope_guard() noexcept
174 if (m_active) m_callback();
179template <
typename Callback>
180sg_detail::scope_guard<Callback>::scope_guard(scope_guard&& other)
noexcept(
181 std::is_nothrow_constructible<Callback, Callback&&>::value)
182 : m_callback(std::forward<Callback>(other.m_callback))
183 , m_active{std::move(other.m_active)}
185 other.m_active =
false;
190template <
typename Callback>
191inline void sg_detail::scope_guard<Callback>::dismiss() noexcept
198template <
typename Callback>
200 std::is_nothrow_constructible<Callback, Callback&&>::value) -> sg_detail::scope_guard<Callback>
202 return sg_detail::scope_guard<Callback>{std::forward<Callback>(callback)};
sg_detail::scope_guard< Callback > make_scope_guard(Callback &&callback) noexcept(std::is_nothrow_constructible< Callback, Callback && >::value)
Creates a scope guard around a callable object.
Main namespace for Lagrange.
Definition: AABBIGL.h:30