TTKMusicPlayer  4.1.3.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 - 2025 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 !TTK_HAS_CXX14
42 template<typename _Tp>
44 using remove_extent_t = typename remove_extent<_Tp>::type;
45 
47 template<typename _Tp>
48 using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
49 #endif
50 
51 #if !defined(_MSC_VER) && !TTK_HAS_CXX14
52 template <typename _Tp, typename _Up = _Tp>
54 inline _Tp exchange(_Tp &__obj, _Up &&__new_val) noexcept
55 {
56  _Tp __old_val = std::move(__obj);
57  __obj = std::forward<_Up>(__new_val);
58  return __old_val;
59 }
60 #endif
61 
62 #if !TTK_HAS_CXX17
63 template <typename _Tp>
64 inline constexpr const _Tp& clamp(const _Tp &_Val, const _Tp &_Min_val, const _Tp &_Max_val)
65 {
66  return TTK::max(_Min_val, TTK::min(_Max_val, _Val));
67 }
68 #endif
69 }
70 
71 #endif // TTKCOMPAT_H
typename remove_all_extents< _Tp >::type remove_all_extents_t
Alias template for remove_all_extents.
Definition: ttkcompat.h:48
typename remove_extent< _Tp >::type remove_extent_t
Alias template for remove_extent.
Definition: ttkcompat.h:44
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:54
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:64