micro-test-plus
4.1.0
µTest++ Testing Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
type-traits-inlines.h
Go to the documentation of this file.
1
/*
2
* This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
* Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
*
5
* Permission to use, copy, modify, and/or distribute this software for any
6
* purpose is hereby granted, under the terms of the MIT license.
7
*
8
* If a copy of the license was not distributed with this file, it can be
9
* obtained from https://opensource.org/licenses/mit.
10
*
11
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12
* released under the terms of the Boost Version 1.0 Software License,
13
* which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14
*/
15
16
// ----------------------------------------------------------------------------
17
42
43
#ifndef MICRO_TEST_PLUS_TYPE_TRAITS_INLINES_H_
44
#define MICRO_TEST_PLUS_TYPE_TRAITS_INLINES_H_
45
46
// ----------------------------------------------------------------------------
47
48
#ifdef __cplusplus
49
50
// ----------------------------------------------------------------------------
51
52
#if defined(__GNUC__)
53
#pragma GCC diagnostic push
54
#if defined(__clang__)
55
#pragma clang diagnostic ignored "-Wc++98-compat"
56
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
57
#endif
58
#endif
59
60
// ============================================================================
61
62
namespace
micro_os_plus::micro_test_plus
63
{
64
namespace
type_traits
65
{
66
// ========================================================================
67
72
template
<
class
T>
73
constexpr
value_base_<T>::value_base_
(
const
T& v) noexcept :
value_
{ v }
74
{
75
}
76
81
template
<
class
T>
82
constexpr
value_base_<T>
::
83
operator T () const noexcept
84
{
85
return
value_
;
86
}
87
92
template
<
class
T>
93
constexpr
T
94
value_base_<T>::get
(
void
)
const
noexcept
95
{
96
return
value_
;
97
}
98
99
// ------------------------------------------------------------------------
100
105
template
<auto N>
106
constexpr
integral_constant<N>::integral_constant
() noexcept
107
:
value_base_
<decltype (N)>{ N }
108
{
109
}
110
116
template
<auto N>
117
constexpr
auto
118
integral_constant<N>::operator-
() const noexcept
119
{
120
return
integral_constant
<-N>{};
121
}
122
123
// ------------------------------------------------------------------------
124
129
template
<
class
T, auto N, auto D, auto Size, auto P>
130
constexpr
floating_point_constant<T, N, D, Size, P>
::
131
operator T () const noexcept
132
{
133
return
value
;
134
}
135
140
template
<
class
T, auto N, auto D, auto Size, auto P>
141
constexpr
T
142
floating_point_constant<T, N, D, Size, P>::get
(
void
)
const
noexcept
143
{
144
return
value
;
145
}
146
152
template
<
class
T, auto N, auto D, auto Size, auto P>
153
constexpr
auto
154
floating_point_constant<T, N, D, Size, P>::operator-
() const noexcept
155
{
156
return
floating_point_constant
<T, N, D, Size, -P>{};
157
}
158
159
// ------------------------------------------------------------------------
160
165
template
<
class
T>
166
constexpr
genuine_integral_value<T>::genuine_integral_value
(
167
const
T& _value) noexcept
168
:
value_base_<T>
{ _value }
169
{
170
}
171
172
// ------------------------------------------------------------------------
173
178
template
<
class
T>
179
constexpr
value<T>::value
(
const
T& _value) noexcept
180
:
value_base_<T>
{ _value }
181
{
182
}
183
184
// ------------------------------------------------------------------------
185
191
template
<
class
T>
192
requires
is_floating_point<T>
193
constexpr
value<T>::value
(
const
T& _value,
const
T precision) noexcept
194
:
value_base_<T>
{ _value }, epsilon{ precision }
195
{
196
}
197
203
template
<
class
T>
204
requires
is_floating_point<T>
205
constexpr
value<T>::value
(
const
T& val)
206
: value{ val,
207
T (1)
208
/ math::pow (T (10),
209
math::den_size<unsigned long long> (val)) }
210
{
211
}
212
213
// ------------------------------------------------------------------------
214
}
// namespace type_traits
215
216
// --------------------------------------------------------------------------
217
}
// namespace micro_os_plus::micro_test_plus
218
219
#if defined(__GNUC__)
220
#pragma GCC diagnostic pop
221
#endif
222
223
// ----------------------------------------------------------------------------
224
225
#endif
// __cplusplus
226
227
// ----------------------------------------------------------------------------
228
229
#endif
// MICRO_TEST_PLUS_TYPE_TRAITS_INLINES_H_
230
231
// ----------------------------------------------------------------------------
micro_os_plus::micro_test_plus::type_traits
Type trait utilities and metaprogramming support for the µTest++ testing framework.
Definition
type-traits-inlines.h:65
micro_os_plus::micro_test_plus
Primary namespace for the µTest++ testing framework.
micro_os_plus::micro_test_plus::type_traits::floating_point_constant
Struct template representing a generic floating point constant with custom size and precision.
Definition
type-traits.h:617
micro_os_plus::micro_test_plus::type_traits::floating_point_constant::operator-
constexpr auto operator-() const noexcept
Unary minus operator.
Definition
type-traits-inlines.h:154
micro_os_plus::micro_test_plus::type_traits::floating_point_constant::get
constexpr T get(void) const noexcept
Getter for the compile-time constant value.
Definition
type-traits-inlines.h:142
micro_os_plus::micro_test_plus::type_traits::floating_point_constant::value
static constexpr auto value
The compile-time constant value.
Definition
type-traits.h:641
micro_os_plus::micro_test_plus::type_traits::genuine_integral_value::genuine_integral_value
constexpr genuine_integral_value(const T &_value) noexcept
Constructs a genuine_integral_value with the specified value.
Definition
type-traits-inlines.h:166
micro_os_plus::micro_test_plus::type_traits::integral_constant::integral_constant
constexpr integral_constant() noexcept
Default constructor. Initialises the base with N.
Definition
type-traits-inlines.h:106
micro_os_plus::micro_test_plus::type_traits::integral_constant::operator-
constexpr auto operator-() const noexcept
Unary minus operator.
Definition
type-traits-inlines.h:118
micro_os_plus::micro_test_plus::type_traits::value_base_::value_
T value_
The stored value.
Definition
type-traits.h:544
micro_os_plus::micro_test_plus::type_traits::value_base_::value_base_
constexpr value_base_(const T &v) noexcept
Constructs a value_base_ with the given value.
Definition
type-traits-inlines.h:73
micro_os_plus::micro_test_plus::type_traits::value_base_::get
constexpr T get(void) const noexcept
Getter for the stored value.
Definition
type-traits-inlines.h:94
micro_os_plus::micro_test_plus::type_traits::value::value
constexpr value(const T &_value) noexcept
Constructs a value object with the specified value.
include
micro-os-plus
micro-test-plus
inlines
type-traits-inlines.h
Generated by
1.17.0