micro-test-plus 5.0.1
µTest++ Testing Framework
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_OS_PLUS_MICRO_TEST_PLUS_INLINES_TYPE_TRAITS_INLINES_H_
44#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_TYPE_TRAITS_INLINES_H_
45
46// ----------------------------------------------------------------------------
47
48#if defined(__cplusplus)
49
50// ----------------------------------------------------------------------------
51
52#if defined(__GNUC__)
53#pragma GCC diagnostic push
54
55#if defined(__clang__)
56#pragma clang diagnostic ignored "-Wc++98-compat"
57#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
58#endif // defined(__clang__)
59#endif // defined(__GNUC__)
60
61// ============================================================================
62
64{
65 namespace type_traits
66 {
67 // ========================================================================
68
73 template <class T>
74 constexpr value_base_<T>::value_base_ (const T& v) noexcept : value_{ v }
75 {
76 }
77
82 template <class T>
83 constexpr value_base_<T>::
84 operator T () const noexcept
85 {
86 return value_;
87 }
88
93 template <class T>
94 constexpr T
95 value_base_<T>::get (void) const noexcept
96 {
97 return value_;
98 }
99
100 // ------------------------------------------------------------------------
101
106 template <auto N>
108 : value_base_<decltype (N)>{ N }
109 {
110 }
111
117 template <auto N>
118 constexpr auto
120 {
121 return integral_constant<-N>{};
122 }
123
124 // ------------------------------------------------------------------------
125
130 template <class T, auto N, auto D, auto Size, auto P>
132 operator T () const noexcept
133 {
134 return value;
135 }
136
141 template <class T, auto N, auto D, auto Size, auto P>
142 constexpr T
144 {
145 return value;
146 }
147
153 template <class T, auto N, auto D, auto Size, auto P>
154 constexpr auto
156 {
157 return floating_point_constant<T, N, D, Size, -P>{};
158 }
159
160 // ------------------------------------------------------------------------
161
166 template <class T>
168 const T& _value) noexcept
169 : value_base_<T>{ _value }
170 {
171 }
172
173 // ------------------------------------------------------------------------
174
175 template <class T>
176 constexpr value<T>::value (const T& _value) noexcept
177 : value_base_<T>{ _value }
178 {
179 }
180
181 // ------------------------------------------------------------------------
182 } // namespace type_traits
183
184 // --------------------------------------------------------------------------
185} // namespace micro_os_plus::micro_test_plus
186
187#if defined(__GNUC__)
188#pragma GCC diagnostic pop
189#endif // defined(__GNUC__)
190
191// ----------------------------------------------------------------------------
192
193#endif // defined(__cplusplus)
194
195// ----------------------------------------------------------------------------
196
197#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_TYPE_TRAITS_INLINES_H_
198
199// ----------------------------------------------------------------------------
Type trait utilities and metaprogramming support for the µTest++ testing framework.
Primary namespace for the µTest++ testing framework.
Struct template representing a generic floating point constant with custom size and precision.
constexpr auto operator-() const noexcept
Unary minus operator.
constexpr T get(void) const noexcept
Getter for the compile-time constant value.
static constexpr auto value
The compile-time constant value.
constexpr genuine_integral_value(const T &_value) noexcept
Constructs a genuine_integral_value with the specified value.
constexpr integral_constant() noexcept
Default constructor. Initialises the base with N.
constexpr auto operator-() const noexcept
Unary minus operator.
constexpr value_base_(const T &v) noexcept
Constructs a value_base_ with the given value.
constexpr T get(void) const noexcept
Getter for the stored value.
constexpr value(const T &_value) noexcept
Constructs a value object with the specified value.