libbio
Loading...
Searching...
No Matches
IsWave.h
Go to the documentation of this file.
1/*
2 * This file is a part of the Biology project by eons LLC.
3 * Biology (aka Develop Biology) is a framework for approaching software
4 * development from a natural sciences perspective.
5 *
6 * Copyright (C) 2022 Séon O'Shannon & eons LLC
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as
10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (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 Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21#pragma once
22
28
29#if BIO_CPP_VERSION >= 11
30#include <type_traits>
31#endif
32
33namespace bio
34{
35namespace type
36{
37
38namespace is_wave_detail
39{
40
41#if BIO_CPP_VERSION < 11
42template <typename Base, typename Derived>
44{
45#if defined(__GNUC__) || defined(__clang__)
46public:
47 static const bool sValue = __is_base_of(Base, Derived);
48#else
49 typedef char Yes;
50 typedef char No[2];
51
52 static Yes Test(Base*); // BIO_RAW_POINTER_ALLOWLIST: SFINAE convertibility probe, not storage
53 static No& Test(...);
54 static Derived* GetDerived(); // BIO_RAW_POINTER_ALLOWLIST: SFINAE probe (unevaluated), not storage
55
56public:
57 static const bool sValue = sizeof(Test(GetDerived())) == sizeof(Yes);
58#endif
59};
60#endif
61
62} // namespace is_wave_detail
63
64#if BIO_CPP_VERSION >= 20
65template <typename T>
66concept WaveType =
67 ::std::derived_from<
68 ::std::remove_cvref_t<
69 ::std::remove_pointer_t<T>
70 >,
72#endif
73
74template <typename T>
76{
80
81#if BIO_CPP_VERSION >= 11
82 static const bool sValue = ::std::is_base_of< physical::Wave, Base >::value;
83#else
84 static const bool sValue =
86#endif
87};
88
89template <typename T>
91{
92 // Primitives (and wrapped primitives) are never Waves.
93 if (IsPrimitive<T>())
94 {
95 return false;
96 }
97
99}
100
101#if BIO_CPP_VERSION >= 20
102template <typename T>
104{
105 return WaveType<T>;
106}
107#endif
108
109} // namespace type
110} // namespace bio
#define BIO_CONSTEXPR
Definition KeywordMacros.h:29
Definition Pointer.h:115
Definition Wave.h:82
static const bool sValue
Definition IsWave.h:57
BIO_CONSTEXPR bool IsWave()
Definition IsWave.h:90
Definition FinalCell.h:29
Definition IsWave.h:76
RemoveConst< NoPointer >::Type Base
Definition IsWave.h:79
static const bool sValue
Definition IsWave.h:84
RemovePointer< NoReference >::Type NoPointer
Definition IsWave.h:78
RemoveReference< T >::Type NoReference
Definition IsWave.h:77