swift
Loading...
Searching...
No Matches
inheritancetraits.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_INHERITANCE_TRAITS_H
7#define SWIFT_MISC_INHERITANCE_TRAITS_H
8
9#include <type_traits>
10
11template <typename T>
13
14namespace swift::misc
15{
16 class CPropertyIndexRef;
17
21 template <typename T, typename = std::void_t<>>
22 struct TBaseOf
23 {
24 using type = void;
25 };
26
27 template <typename T>
28 struct TBaseOf<T, std::void_t<typename T::base_type>>
29 {
30 using type = typename T::base_type;
31 };
33
37 template <typename T>
38 inline constexpr bool THasMetaBaseV = QMetaTypeId<typename TBaseOf<T>::type>::Defined;
39
43 template <class T>
45 {
47 using type = std::conditional_t<THasMetaBaseV<T>, typename TBaseOf<T>::type, void>;
48 };
49
54 template <typename T, typename = std::void_t<>>
56 {
57 using type = void;
58 };
59
60 template <typename T>
61 struct TIndexBaseOf<T, std::void_t<decltype(std::declval<typename T::base_type>().propertyByIndex(
62 std::declval<CPropertyIndexRef>()))>>
63 {
64 using type = typename T::base_type;
65 };
67
71 template <class T>
72 using TBaseOfT = typename TBaseOf<T>::type;
73
77 template <class T>
79
83 template <class T>
85} // namespace swift::misc
86
87#endif // SWIFT_MISC_INHERITANCE_TRAITS_H
Free functions in swift::misc.
typename TMetaBaseOf< T >::type TMetaBaseOfT
Alias for typename TMetaBaseOf<T>::type.
typename TBaseOf< T >::type TBaseOfT
Alias for typename TBaseOf<T>::type.
typename TIndexBaseOf< T >::type TIndexBaseOfT
Alias for typename TIndexBaseOf<T>::type.
constexpr bool THasMetaBaseV
True if T has a member typedef base_type which is a registered metatype.
If T has a member typedef base_type, this trait will obtain it, otherwise void.
If T has a member typedef base_type which has a member propertyByIndex, this trait will obtain it,...
It T has a member typedef base_type which is a registered metatype, this trait will obtain it,...
std::conditional_t< THasMetaBaseV< T >, typename TBaseOf< T >::type, void > type
Type of T::base_type, or void if not declared.