/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once namespace base { template inline Type take(Type &value) { return std::exchange(value, Type {}); } template inline Type duplicate(const Type &value) { return value; } template inline constexpr size_t array_size(const Type(&)[Size]) { return Size; } template inline bool contains(const Container &container, const T &value) { const auto end = std::end(container); return std::find(std::begin(container), end, value) != end; } } // namespace base template inline void accumulate_max(T &a, const T &b) { if (a < b) a = b; } template inline void accumulate_min(T &a, const T &b) { if (a > b) a = b; } template QLatin1String qstr(const char(&string)[Size]) { return QLatin1String(string, Size - 1); }