TTKMusicPlayer
4.2.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
TTKCommon
base
ttktraits.h
Go to the documentation of this file.
1
#ifndef TTKTRAITS_H
2
#define TTKTRAITS_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
#if 1
23
#define TTK_DECLARE_HAS_MEMBER(__trait_name__) \
24
template <typename T, typename... Args> \
25
struct has_member_##__trait_name__ \
26
{ \
27
private: \
28
template <typename U> \
29
static auto test(int)->decltype(std::declval<U>().__trait_name__(std::declval<Args>() ...), std::true_type()); \
30
template <typename U> \
31
static std::false_type test(...); \
32
public: \
33
static constexpr bool value = std::is_same<decltype(test<T>(0)), std::true_type>::value; \
34
}
35
#else
36
#define TTK_DECLARE_HAS_MEMBER(__trait_name__, __member_name__) \
37
template <typename T> \
38
struct __trait_name__ \
39
{ \
40
typedef typename std::remove_const<T>::type check_type; \
41
struct base { void __member_name__() {}}; \
42
struct mixin : public base, public check_type {}; \
43
template <void (base::*)()> struct aux {}; \
44
template <typename U> static std::false_type test(aux<&U::__member_name__>*); \
45
template <typename U> static std::true_type test(...); \
46
static constexpr bool value = (sizeof(std::true_type) == sizeof(test<mixin>(0))); \
47
}
48
#endif
49
50
#define TTK_DECLARE_GLOBAL_SIGNATURE(__trait_name__, __func_name__) \
51
std::nullptr_t __func_name__(...); \
52
template <typename T> \
53
struct __trait_name__ \
54
{ \
55
template <typename U, U> struct helper; \
56
template <typename U> static std::uint8_t test(helper<U*, &__func_name__>*); \
57
template <typename U> static std::uint16_t test(...); \
58
static constexpr bool value = sizeof(test<T>(0)) == sizeof(std::uint8_t); \
59
}
60
61
#define TTK_DECLARE_CLASS_SIGNATURE(__trait_name__, __func_name__) \
62
template <typename Void, typename Obj, typename Func> \
63
struct __trait_name__ : std::false_type {}; \
64
template <typename Obj, typename Func> \
65
struct __trait_name__<std::void_t<decltype(static_cast<Func Obj::*>(&Obj::__func_name__))>, Obj, Func> : std::true_type {}; \
66
template <typename Obj, typename Func> \
67
using __trait_name__##Check = __trait_name__<void, Obj, Func>;
68
69
#endif // TTKTRAITS_H
Generated on Sat Jul 19 2025 16:52:59 for TTKMusicPlayer by
1.8.8