Develop Biology
The language of life
IsPrimitive.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) 2021 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
22#pragma once
23
26#include "IsPointer.h"
27
28//@formatter:off
29#if BIO_CPP_VERSION < 11
30 #include <string>
31 #include <stdint.h>
32#else
33 #include <type_traits>
34 #include <cstdint>
35#endif
36//@formatter:on
37
38namespace bio {
39namespace utility {
40
41//@formatter:off
42#if BIO_CPP_VERSION < 11
43 template<typename T>
44 struct IsPrimitiveImplementation {static const bool m_value = false;};
45#endif
46//@formatter:on
47
56template < typename T >
57bool IsPrimitive(const T t)
58{
59 BIO_SANITIZE_AT_SAFETY_LEVEL_2(!IsPointer< T >(), ,
60 return IsPrimitive(*t));
61
62 //@formatter:off
63 #if BIO_CPP_VERSION < 11
65 #else
66 return std::is_fundamental<T>::value;
67 #endif
68 //@formatter:on
69}
70
77template < typename T >
79{
80 if (IsPointer< T >())
81 {
82 return false;
83 }
84 //@formatter:off
85 #if BIO_CPP_VERSION < 11
87 #else
88 return std::is_fundamental<T>::value;
89 #endif
90 //@formatter:on
91}
92
93#if BIO_CPP_VERSION < 11
94
95template <>
97{
98 static const bool m_value = true;
99};
100
101template <>
103{
104 static const bool m_value = true;
105};
106
107template <>
109{
110 static const bool m_value = true;
111};
112
113//This is int8_t & may cause compiler errors.
114//template <>
115//struct IsPrimitiveImplementation< char > {static const bool m_value = true;};
116
117template <>
118struct IsPrimitiveImplementation< std::string >
119{
120 static const bool m_value = true;
121};
122
123template <>
125{
126 static const bool m_value = true;
127};
128
129template <>
131{
132 static const bool m_value = true;
133};
134
135template <>
137{
138 static const bool m_value = true;
139};
140
141template <>
143{
144 static const bool m_value = true;
145};
146
147template <>
149{
150 static const bool m_value = true;
151};
152
153template <>
155{
156 static const bool m_value = true;
157};
158
159template <>
161{
162 static const bool m_value = true;
163};
164
165template <>
167{
168 static const bool m_value = true;
169};
170
171#endif
172
173} //utility namespace
174} //bio namespace
#define BIO_SANITIZE_AT_SAFETY_LEVEL_2(test, success, failure)
bool IsPrimitive(const T t)
Definition: IsPrimitive.h:57
Definition: Cell.h:31