Skip to main content

exceptions-inlines.h File

C++ header file with inline implementations for the µTest++ exceptions comparators. More...

Namespaces Index​

namespacemicro_os_plus

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

namespacemicro_test_plus

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

Functions Index​

template <class Callable_T>
autonothrow (Callable_T &&func)

Checks whether a callable does not throw any exception, for expect() or require(). More...

template <class Callable_T>
autothrows (Callable_T &&func)

Checks whether a callable throws any exception, for expect() or require(). More...

template <class Exception_T, class Callable_T>
autothrows (Callable_T &&func)

Checks whether a callable throws a specific exception, for expect() or require(). More...

Description​

C++ header file with inline implementations for the µTest++ exceptions comparators.

This header provides the inline implementations for the exception-checking function templates used within the µTest++ framework (throws() and nothrow()), which create the detail::throws_op and detail::nothrow_op comparator objects.

All definitions reside within the micro_os_plus::micro_test_plus namespace.

This file is included by exceptions.h; the applications include micro-os-plus/micro-test-plus.h, not this file.

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.0 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
35
36#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_EXCEPTIONS_INLINES_H_
37#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_EXCEPTIONS_INLINES_H_
38
39// ----------------------------------------------------------------------------
40
41#if defined(__cplusplus)
42
43// ----------------------------------------------------------------------------
44
45#if defined(__GNUC__)
46#pragma GCC diagnostic push
47
48#pragma GCC diagnostic ignored "-Waggregate-return"
49#if defined(__clang__)
50#pragma clang diagnostic ignored "-Wc++98-compat"
51#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
52#endif // defined(__clang__)
53#endif // defined(__GNUC__)
54
55// ============================================================================
56
58{
59 // --------------------------------------------------------------------------
60 // Exceptions related comparators.
61
62#if defined(__cpp_exceptions)
63
75 template <class Exception_T, class Callable_T>
76 requires std::invocable<Callable_T&>
77 auto
78 throws (Callable_T&& func)
79 {
81 }
82
94 template <class Callable_T>
95 requires std::invocable<Callable_T&>
96 auto
97 throws (Callable_T&& func)
98 {
99 return detail::throws_op<>{ func };
100 }
101
113 template <class Callable_T>
114 requires std::invocable<Callable_T&>
115 auto
116 nothrow (Callable_T&& func)
117 {
118 return detail::nothrow_op{ func };
119 }
120
121#endif // defined(__cpp_exceptions)
122
123 // --------------------------------------------------------------------------
124} // namespace micro_os_plus::micro_test_plus
125
126#if defined(__GNUC__)
127#pragma GCC diagnostic pop
128#endif // defined(__GNUC__)
129
130// ----------------------------------------------------------------------------
131
132#endif // defined(__cplusplus)
133
134// ----------------------------------------------------------------------------
135
136#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_EXCEPTIONS_INLINES_H_
137
138// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.