2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Use gsl::finally() instead of base::scope_guard().

This commit is contained in:
John Preston
2017-08-13 19:16:48 +03:00
parent 012d59ab42
commit 17cef93ac0
7 changed files with 8 additions and 35 deletions

View File

@@ -109,31 +109,6 @@ inline constexpr D up_cast(T object) {
return internal::up_cast_helper<D>(std::integral_constant<bool, std::is_base_of<DV, TV>::value || std::is_same<DV, TV>::value>(), object);
}
template <typename Lambda>
class scope_guard_helper {
public:
scope_guard_helper(Lambda on_scope_exit) : _handler(std::move(on_scope_exit)) {
}
void dismiss() {
_dismissed = true;
}
~scope_guard_helper() {
if (!_dismissed) {
_handler();
}
}
private:
Lambda _handler;
bool _dismissed = false;
};
template <typename Lambda>
scope_guard_helper<Lambda> scope_guard(Lambda on_scope_exit) {
return scope_guard_helper<Lambda>(std::move(on_scope_exit));
}
template <typename Container, typename T>
inline bool contains(const Container &container, const T &value) {
auto end = std::end(container);