Skip to main content

operators.h File

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

Included Headers​

#include "type-traits.h" #include <string_view> #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_OS_PLUS_MICRO_TEST_PLUS_OPERATORS_H_
47#define MICRO_OS_PLUS_MICRO_TEST_PLUS_OPERATORS_H_
48
49// ----------------------------------------------------------------------------
50
51#if defined(__cplusplus)
52
53// ----------------------------------------------------------------------------
54
55#if __has_include("micro-os-plus/project-config.h")
56#include "micro-os-plus/project-config.h"
57#endif // __has_include("micro-os-plus/project-config.h")
58
59#if __has_include("micro-os-plus/micro-test-plus-defines.h")
60#include "micro-os-plus/micro-test-plus-defines.h"
61#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
62
63#include "type-traits.h"
64
65#include <string_view>
66
67// ----------------------------------------------------------------------------
68
69#if defined(__GNUC__)
70#pragma GCC diagnostic push
71
72#pragma GCC diagnostic ignored "-Wpadded"
73#pragma GCC diagnostic ignored "-Waggregate-return"
74#if defined(__clang__)
75#pragma clang diagnostic ignored "-Wc++98-compat"
76#endif // defined(__clang__)
77#endif // defined(__GNUC__)
78
79// ===========================================================================
80
82{
83 // --------------------------------------------------------------------------
84
117 namespace operators
118 {
128 [[nodiscard]] constexpr auto
129 operator==(std::string_view lhs, std::string_view rhs);
130
140 [[nodiscard]] constexpr auto
141 operator!=(std::string_view lhs, std::string_view rhs);
142
157 template <class Lhs_T, class Rhs_T>
158 requires (type_traits::container_like<Lhs_T>
159 and type_traits::container_like<Rhs_T>)
160 [[nodiscard]] constexpr auto
161 operator== (const Lhs_T& lhs, const Rhs_T& rhs);
162
177 template <class Lhs_T, class Rhs_T>
178 requires (type_traits::container_like<Lhs_T>
179 and type_traits::container_like<Rhs_T>)
180 [[nodiscard]] constexpr auto
181 operator!= (const Lhs_T& lhs, const Rhs_T& rhs);
182
196 template <class Lhs_T, class Rhs_T>
197 requires type_traits::any_op<Lhs_T, Rhs_T>
198 [[nodiscard]] constexpr auto
199 operator==(const Lhs_T& lhs, const Rhs_T& rhs);
200
214 template <class Lhs_T, class Rhs_T>
215 requires type_traits::any_op<Lhs_T, Rhs_T>
216 [[nodiscard]] constexpr auto
217 operator!=(const Lhs_T& lhs, const Rhs_T& rhs);
218
232 template <class Lhs_T, class Rhs_T>
233 requires type_traits::any_op<Lhs_T, Rhs_T>
234 [[nodiscard]] constexpr auto
235 operator>(const Lhs_T& lhs, const Rhs_T& rhs);
236
250 template <class Lhs_T, class Rhs_T>
251 requires type_traits::any_op<Lhs_T, Rhs_T>
252 [[nodiscard]] constexpr auto
253 operator>=(const Lhs_T& lhs, const Rhs_T& rhs);
254
268 template <class Lhs_T, class Rhs_T>
269 requires type_traits::any_op<Lhs_T, Rhs_T>
270 [[nodiscard]] constexpr auto
271 operator<(const Lhs_T& lhs, const Rhs_T& rhs);
272
286 template <class Lhs_T, class Rhs_T>
287 requires type_traits::any_op<Lhs_T, Rhs_T>
288 [[nodiscard]] constexpr auto
289 operator<=(const Lhs_T& lhs, const Rhs_T& rhs);
290
304 template <class Lhs_T, class Rhs_T>
305 requires type_traits::any_op<Lhs_T, Rhs_T>
306 [[nodiscard]] constexpr auto
307 operator and (const Lhs_T& lhs, const Rhs_T& rhs);
308
322 template <class Lhs_T, class Rhs_T>
323 requires type_traits::any_op<Lhs_T, Rhs_T>
324 [[nodiscard]] constexpr auto
325 operator or (const Lhs_T& lhs, const Rhs_T& rhs);
326
339 template <class T>
340 requires type_traits::is_op<T>
341 [[nodiscard]] constexpr auto
342 operator not(const T& t);
343
344 // ------------------------------------------------------------------------
345 } // namespace operators
346
347 // --------------------------------------------------------------------------
348} // namespace micro_os_plus::micro_test_plus
349
350#if defined(__GNUC__)
351#pragma GCC diagnostic pop
352#endif // defined(__GNUC__)
353
354// ----------------------------------------------------------------------------
355
356#endif // defined(__cplusplus)
357
358// ============================================================================
359// Templates, inlines & constexpr implementations.
360
362
363// ----------------------------------------------------------------------------
364
365#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_OPERATORS_H_
366
367// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.