Skip to main content

operators.h File

C++ header file with declarations for the µTest++ operators. More...

Included Headers

#include <string_view> #include "type-traits.h" #include "inlines/operators-inlines.h"

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 declarations for the µTest++ operators.

This header provides the declarations for the custom operator overloads used within the µTest++ framework. It defines interfaces for equality, inequality, relational, and logical operators tailored for use with the framework’s strongly-typed constants, wrappers, containers, and string views.

These operator overloads enable expressive, concise, and type-safe test assertions, supporting both compile-time and run-time evaluation. The operators are selectively enabled for types recognised by the framework, minimising the risk of conflicts with user-defined or standard operators.

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.

The header files are organised within the include/micro-os-plus/micro-test-plus folder to maintain a structured and modular codebase.

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
45
46#ifndef MICRO_TEST_PLUS_OPERATORS_H_
47#define MICRO_TEST_PLUS_OPERATORS_H_
48
49// ----------------------------------------------------------------------------
50
51#ifdef __cplusplus
52
53// ----------------------------------------------------------------------------
54
55#include <string_view>
56
57#include "type-traits.h"
58
59// ----------------------------------------------------------------------------
60
61#if defined(__GNUC__)
62#pragma GCC diagnostic push
63#pragma GCC diagnostic ignored "-Wpadded"
64#pragma GCC diagnostic ignored "-Waggregate-return"
65#if defined(__clang__)
66#pragma clang diagnostic ignored "-Wc++98-compat"
67#endif
68#endif
69
70// ===========================================================================
71
73{
74 // --------------------------------------------------------------------------
75
108 namespace operators
109 {
119 [[nodiscard]] constexpr auto
120 operator==(std::string_view lhs, std::string_view rhs);
121
131 [[nodiscard]] constexpr auto
132 operator!=(std::string_view lhs, std::string_view rhs);
133
148 template <class Lhs_T, class Rhs_T>
149 requires (type_traits::container_like<Lhs_T>
150 and type_traits::container_like<Rhs_T>)
151 [[nodiscard]] constexpr auto
152 operator== (const Lhs_T& lhs, const Rhs_T& rhs);
153
168 template <class Lhs_T, class Rhs_T>
169 requires (type_traits::container_like<Lhs_T>
170 and type_traits::container_like<Rhs_T>)
171 [[nodiscard]] constexpr auto
172 operator!= (const Lhs_T& lhs, const Rhs_T& rhs);
173
187 template <class Lhs_T, class Rhs_T>
188 requires type_traits::any_op<Lhs_T, Rhs_T>
189 [[nodiscard]] constexpr auto
190 operator==(const Lhs_T& lhs, const Rhs_T& rhs);
191
205 template <class Lhs_T, class Rhs_T>
206 requires type_traits::any_op<Lhs_T, Rhs_T>
207 [[nodiscard]] constexpr auto
208 operator!=(const Lhs_T& lhs, const Rhs_T& rhs);
209
223 template <class Lhs_T, class Rhs_T>
224 requires type_traits::any_op<Lhs_T, Rhs_T>
225 [[nodiscard]] constexpr auto
226 operator>(const Lhs_T& lhs, const Rhs_T& rhs);
227
241 template <class Lhs_T, class Rhs_T>
242 requires type_traits::any_op<Lhs_T, Rhs_T>
243 [[nodiscard]] constexpr auto
244 operator>=(const Lhs_T& lhs, const Rhs_T& rhs);
245
259 template <class Lhs_T, class Rhs_T>
260 requires type_traits::any_op<Lhs_T, Rhs_T>
261 [[nodiscard]] constexpr auto
262 operator<(const Lhs_T& lhs, const Rhs_T& rhs);
263
277 template <class Lhs_T, class Rhs_T>
278 requires type_traits::any_op<Lhs_T, Rhs_T>
279 [[nodiscard]] constexpr auto
280 operator<=(const Lhs_T& lhs, const Rhs_T& rhs);
281
295 template <class Lhs_T, class Rhs_T>
296 requires type_traits::any_op<Lhs_T, Rhs_T>
297 [[nodiscard]] constexpr auto
298 operator and (const Lhs_T& lhs, const Rhs_T& rhs);
299
313 template <class Lhs_T, class Rhs_T>
314 requires type_traits::any_op<Lhs_T, Rhs_T>
315 [[nodiscard]] constexpr auto
316 operator or (const Lhs_T& lhs, const Rhs_T& rhs);
317
330 template <class T>
331 requires type_traits::is_op<T>
332 [[nodiscard]] constexpr auto
333 operator not(const T& t);
334
335 // ------------------------------------------------------------------------
336 } // namespace operators
337
338 // --------------------------------------------------------------------------
339} // namespace micro_os_plus::micro_test_plus
340
341#if defined(__GNUC__)
342#pragma GCC diagnostic pop
343#endif
344
345// ----------------------------------------------------------------------------
346
347#endif // __cplusplus
348
349// ============================================================================
350// Templates & constexpr implementations.
351
353
354// ----------------------------------------------------------------------------
355
356#endif // MICRO_TEST_PLUS_OPERATORS_H_
357
358// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.