micro-test-plus 3.2.2
µTest++ Testing Framework
Loading...
Searching...
No Matches
math.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 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any 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
9 * be 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
48
49#ifndef MICRO_TEST_PLUS_MATH_H_
50#define MICRO_TEST_PLUS_MATH_H_
51
52// ----------------------------------------------------------------------------
53
54#ifdef __cplusplus
55
56// ----------------------------------------------------------------------------
57
58#include <array>
59
60// ----------------------------------------------------------------------------
61
62#if defined(__GNUC__)
63#pragma GCC diagnostic push
64#pragma GCC diagnostic ignored "-Wconversion"
65#if defined(__clang__)
66#pragma clang diagnostic ignored "-Wc++98-compat"
67#endif
68#endif
69
71{
72 // --------------------------------------------------------------------------
73
93 namespace math
94 {
104 template <class T>
105 [[nodiscard]] constexpr auto
106 abs (const T t) -> T;
107
118 template <class T>
119 [[nodiscard]] constexpr auto
120 min_value (const T& lhs, const T& rhs) -> const T&;
121
135 template <class T, class Exp_T>
136 [[nodiscard]] constexpr auto
137 pow (const T base, const Exp_T exp) -> T;
138
150 template <class T, char... Cs>
151 [[nodiscard]] constexpr auto
152 num (void) -> T;
153
165 template <class T, char... Cs>
166 [[nodiscard]] constexpr auto
167 den (void) -> T;
168
180 template <class T, char... Cs>
181 [[nodiscard]] constexpr auto
182 den_size (void) -> T;
183
195 template <class T, class Value_T>
196 [[nodiscard]] constexpr auto
197 den_size (Value_T value) -> T;
198
199 // ------------------------------------------------------------------------
200 } // namespace math
201
202 // --------------------------------------------------------------------------
203} // namespace micro_os_plus::micro_test_plus
204
205#if defined(__GNUC__)
206#pragma GCC diagnostic pop
207#endif
208
209// ----------------------------------------------------------------------------
210
211#endif // __cplusplus
212
213// ----------------------------------------------------------------------------
214
215#endif // MICRO_TEST_PLUS_MATH_H_
216
217// ----------------------------------------------------------------------------
Mathematical utilities for the µTest++ testing framework.
constexpr auto den(void) -> T
Computes the decimal part of a number represented as an array of characters.
constexpr auto abs(const T t) -> T
Computes the absolute value of a given comparable value.
constexpr auto pow(const T base, const Exp_T exp) -> T
Generic exponentiation function to compute the power of a base raised to an exponent.
constexpr auto den_size(void) -> T
Computes the number of decimal places in a number represented as an array of characters.
constexpr auto num(void) -> T
Computes the integral value of a number represented as an array of characters.
constexpr auto min_value(const T &lhs, const T &rhs) -> const T &
Computes the minimum of two comparable values.
Primary namespace for the µTest++ testing framework.