micro-test-plus 4.1.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
operators.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
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// ----------------------------------------------------------------------------
constexpr auto operator<=(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 loca...
constexpr auto operator<(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).
constexpr auto operator>=(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 l...
constexpr auto operator>(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).
constexpr auto operator!=(std::string_view lhs, std::string_view rhs)
Non-equality operator for string_view objects.
constexpr auto operator==(std::string_view lhs, std::string_view rhs)
Equality operator for string_view objects.
Custom operator overloads for expressive and type-safe test assertions.
Primary namespace for the µTest++ testing framework.
C++ header file with inline implementations for the µTest++ operator overloads.
C++ header file with declarations for the µTest++ type trait utilities and metaprogramming support.