micro-test-plus 6.0.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
math-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
41
42#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_MATH_INLINES_H_
43#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_MATH_INLINES_H_
44
45// ----------------------------------------------------------------------------
46
47#if defined(__cplusplus)
48
49// ----------------------------------------------------------------------------
50
51#include <cstdint>
52
53// ----------------------------------------------------------------------------
54
55#if defined(__GNUC__)
56#pragma GCC diagnostic push
57
58#pragma GCC diagnostic ignored "-Waggregate-return"
59#if defined(__clang__)
60#pragma clang diagnostic ignored "-Wc++98-compat"
61#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
62#pragma clang diagnostic ignored "-Wc++20-compat"
63#endif // defined(__clang__)
64#endif // defined(__GNUC__)
65
66// ============================================================================
67
69{
70 // --------------------------------------------------------------------------
71
72 namespace detail::math
73 {
74
86 template <class T>
87 constexpr auto
88 abs (const T t) noexcept -> T
89 {
90 return t < T{} ? -t : t;
91 }
92
93#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
104 template <class T>
105 constexpr auto
106 min_value (const T& lhs, const T& rhs) noexcept -> const T&
107 {
108 return (rhs < lhs) ? rhs : lhs;
109 }
110#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
111
112 } // namespace detail::math
113
114 // --------------------------------------------------------------------------
115} // namespace micro_os_plus::micro_test_plus
116
117#if defined(__GNUC__)
118#pragma GCC diagnostic pop
119#endif // defined(__GNUC__)
120
121// ----------------------------------------------------------------------------
122
123#endif // defined(__cplusplus)
124
125// ----------------------------------------------------------------------------
126
127#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_MATH_INLINES_H_
128
129// ----------------------------------------------------------------------------
Internal mathematical utilities for the µTest++ testing framework.
Definition deprecated.h:123
constexpr auto abs(const T t) noexcept -> T
Computes the absolute value of a given comparable value.
constexpr auto min_value(const T &lhs, const T &rhs) noexcept -> const T &
Computes the minimum of two comparable values.
Primary namespace for the µTest++ testing framework.