2017-08-14 12:47:46 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-08-14 12:47:46 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-08-14 12:47:46 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace base {
|
|
|
|
|
2017-09-04 11:24:35 +00:00
|
|
|
template <typename Type>
|
|
|
|
inline Type take(Type &value) {
|
|
|
|
return std::exchange(value, Type {});
|
|
|
|
}
|
|
|
|
|
2017-11-23 09:58:12 +00:00
|
|
|
template <typename Type>
|
|
|
|
inline Type duplicate(const Type &value) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2017-09-04 11:24:35 +00:00
|
|
|
template <typename Type, size_t Size>
|
|
|
|
inline constexpr size_t array_size(const Type(&)[Size]) {
|
|
|
|
return Size;
|
|
|
|
}
|
|
|
|
|
2017-08-14 12:47:46 +00:00
|
|
|
} // namespace base
|
2018-08-08 20:11:28 +00:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
inline void accumulate_max(T &a, const T &b) { if (a < b) a = b; }
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
inline void accumulate_min(T &a, const T &b) { if (a > b) a = b; }
|
|
|
|
|
|
|
|
template <size_t Size>
|
|
|
|
QLatin1String qstr(const char(&string)[Size]) {
|
|
|
|
return QLatin1String(string, Size - 1);
|
|
|
|
}
|