TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkcompat.h
Go to the documentation of this file.
1 #ifndef TTKCOMPAT_H
2 #define TTKCOMPAT_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module project
6  * Copyright (C) 2015 - 2024 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include "ttkglobal.h"
23 
24 namespace TTK
25 {
26 template <typename _Tp>
27 inline constexpr const _Tp& min(const _Tp &a, const _Tp &b)
28 {
29  return (a < b) ? a : b;
30 }
31 
32 template <typename _Tp>
33 inline constexpr const _Tp& max(const _Tp &a, const _Tp &b)
34 {
35  return (a < b) ? b : a;
36 }
37 }
38 
39 namespace std
40 {
41 #if !defined(_MSC_VER) && !TTK_HAS_CXX14
42 template <typename _Tp, typename _Up = _Tp>
44 inline _Tp exchange(_Tp &__obj, _Up &&__new_val) noexcept
45 {
46  _Tp __old_val = std::move(__obj);
47  __obj = std::forward<_Up>(__new_val);
48  return __old_val;
49 }
50 #endif
51 
52 #if !TTK_HAS_CXX17
53 template <typename _Tp>
54 inline constexpr const _Tp& clamp(const _Tp &_Val, const _Tp &_Min_val, const _Tp &_Max_val)
55 {
56  return TTK::max(_Min_val, TTK::min(_Max_val, _Val));
57 }
58 #endif
59 }
60 
61 #endif // TTKCOMPAT_H
Definition: ttkcompat.h:39
_Tp exchange(_Tp &__obj, _Up &&__new_val) noexcept
Assign __new_val to __obj and return its previous value.
Definition: ttkcompat.h:44
constexpr const _Tp & max(const _Tp &a, const _Tp &b)
Definition: ttkcompat.h:33
The namespace of the process utils.
Definition: ttkcompat.h:24
constexpr const _Tp & min(const _Tp &a, const _Tp &b)
Definition: ttkcompat.h:27
constexpr const _Tp & clamp(const _Tp &_Val, const _Tp &_Min_val, const _Tp &_Max_val)
Definition: ttkcompat.h:54