Skip to main content

operators-inlines.h File

C++ header file with inline implementations for the µTest++ operator overloads. More...

Included Headers

Namespaces Index

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_test_plus

Primary namespace for the µTest++ testing framework. More...

namespaceoperators

Custom operator overloads for expressive and type-safe test assertions. More...

Operators Index

template <class Lhs_T, class Rhs_T>
constexpr autooperator and (const Lhs_T &lhs, const Rhs_T &rhs)

Logical && (and) operator. Matches only if at least one operand is of local type (derived from local op). More...

template <class T>
constexpr autooperator not (const T &t)

Logical ! (not) operator. Matches only if the operand is of local type (derived from local op). More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator or (const Lhs_T &lhs, const Rhs_T &rhs)

Logical || (or) operator. Matches only if at least one operand is of local type (derived from local op). More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator!= (const Lhs_T &lhs, const Rhs_T &rhs)

Non-equality operator for custom types. Matches only if at least one operand is of local type. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator!= (const Lhs_T &lhs, const Rhs_T &rhs)

Non-equality operator for containers. More...

constexpr autooperator!= (std::string_view lhs, std::string_view rhs)

Non-equality operator for string_view objects. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator< (const Lhs_T &lhs, const Rhs_T &rhs)

Less than operator. Matches only if at least one operand is of local type (derived from local op). More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator<= (const Lhs_T &lhs, const Rhs_T &rhs)

Less than or equal operator. Matches only if at least one operand is of local type (derived from local op). More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator== (const Lhs_T &lhs, const Rhs_T &rhs)

Equality operator for custom types. Matches only if at least one operand is of local type. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator== (const Lhs_T &lhs, const Rhs_T &rhs)

Equality operator for containers. More...

constexpr autooperator== (std::string_view lhs, std::string_view rhs)

Equality operator for string_view objects. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator> (const Lhs_T &lhs, const Rhs_T &rhs)

Greater than operator. Matches only if at least one operand is of local type (derived from local op). More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator>= (const Lhs_T &lhs, const Rhs_T &rhs)

Greater than or equal operator. Matches only if at least one operand is of local type (derived from local op). More...

Description

C++ header file with inline implementations for the µTest++ operator overloads.

This header provides the inline implementations for all operator overloads declared in operators.h. Each operator constructs and returns the appropriate comparator or logical object from the detail namespace.

Separating the implementations from the declarations keeps operators.h concise and focused on the interface, whilst grouping all operator bodies here for maintainability.

All definitions reside within the micro_os_plus::micro_test_plus::operators namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.

This file is intended solely for internal use within the framework and should not be included directly by user code.

File Listing

The file content with the documentation metadata removed is:

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 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
39
40#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_OPERATORS_INLINES_H_
41#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_OPERATORS_INLINES_H_
42
43// ----------------------------------------------------------------------------
44
45#if defined(__cplusplus)
46
47// ----------------------------------------------------------------------------
48
50
51// ----------------------------------------------------------------------------
52
53#if defined(__GNUC__)
54#pragma GCC diagnostic push
55
56#pragma GCC diagnostic ignored "-Waggregate-return"
57#if defined(__clang__)
58#pragma clang diagnostic ignored "-Wc++98-compat"
59#endif // defined(__clang__)
60#endif // defined(__GNUC__)
61
62// ============================================================================
63
65{
66 namespace operators
67 {
68 // ========================================================================
69
76 constexpr auto
77 operator==(std::string_view lhs, std::string_view rhs)
78 {
79 return detail::eq_{ lhs, rhs };
80 }
81
88 constexpr auto
89 operator!=(std::string_view lhs, std::string_view rhs)
90 {
91 return detail::ne_{ lhs, rhs };
92 }
93
103 template <class Lhs_T, class Rhs_T>
106 constexpr auto
107 operator== (const Lhs_T& lhs, const Rhs_T& rhs)
108 {
109 return detail::eq_{ lhs, rhs };
110 }
111
121 template <class Lhs_T, class Rhs_T>
124 constexpr auto
125 operator!= (const Lhs_T& lhs, const Rhs_T& rhs)
126 {
127 return detail::ne_{ lhs, rhs };
128 }
129
136 template <class Lhs_T, class Rhs_T>
138 constexpr auto
139 operator==(const Lhs_T& lhs, const Rhs_T& rhs)
140 {
141 return detail::eq_{ lhs, rhs };
142 }
143
150 template <class Lhs_T, class Rhs_T>
152 constexpr auto
153 operator!=(const Lhs_T& lhs, const Rhs_T& rhs)
154 {
155 return detail::ne_{ lhs, rhs };
156 }
157
164 template <class Lhs_T, class Rhs_T>
166 constexpr auto
167 operator>(const Lhs_T& lhs, const Rhs_T& rhs)
168 {
169 return detail::gt_{ lhs, rhs };
170 }
171
179 template <class Lhs_T, class Rhs_T>
181 constexpr auto
182 operator>=(const Lhs_T& lhs, const Rhs_T& rhs)
183 {
184 return detail::ge_{ lhs, rhs };
185 }
186
193 template <class Lhs_T, class Rhs_T>
195 constexpr auto
196 operator<(const Lhs_T& lhs, const Rhs_T& rhs)
197 {
198 return detail::lt_{ lhs, rhs };
199 }
200
208 template <class Lhs_T, class Rhs_T>
210 constexpr auto
211 operator<=(const Lhs_T& lhs, const Rhs_T& rhs)
212 {
213 return detail::le_{ lhs, rhs };
214 }
215
222 template <class Lhs_T, class Rhs_T>
224 constexpr auto
225 operator and (const Lhs_T& lhs, const Rhs_T& rhs)
226 {
227 return detail::and_{ lhs, rhs };
228 }
229
236 template <class Lhs_T, class Rhs_T>
238 constexpr auto
239 operator or (const Lhs_T& lhs, const Rhs_T& rhs)
240 {
241 return detail::or_{ lhs, rhs };
242 }
243
250 template <class T>
252 constexpr auto
253 operator not(const T& t)
254 {
255 return detail::not_{ t };
256 }
257
258 // ------------------------------------------------------------------------
259 } // namespace operators
260
261 // --------------------------------------------------------------------------
262} // namespace micro_os_plus::micro_test_plus
263
264#if defined(__GNUC__)
265#pragma GCC diagnostic pop
266#endif // defined(__GNUC__)
267
268// ----------------------------------------------------------------------------
269
270#endif // defined(__cplusplus)
271
272// ----------------------------------------------------------------------------
273
274#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_OPERATORS_INLINES_H_
275
276// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.