Skip to main content

literals.h File

C++ header file with declarations for the µTest++ user-defined literals and type wrappers. More...

Included Headers

#include <cstdint> #include "type-traits.h" #include "math.h" #include "inlines/literals-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...

namespaceliterals

User-defined literals and type wrappers for the µTest++ testing framework. More...

Classes Index

struct_t<T>

Deprecated generic strongly-typed wrapper for explicit type conversion. More...

structto_t<T>

Generic strongly-typed wrapper for explicit type conversion. More...

Operators Index

constexpr autooperator""_b (const char *name, decltype(sizeof("")) size)

User-defined literal operator to convert to bool. More...

template <char... Cs>
constexpr autooperator""_c ()

User-defined literal operator to convert to char. More...

template <char... Cs>
constexpr autooperator""_d ()

User-defined literal operator to convert to double. More...

template <char... Cs>
constexpr autooperator""_f ()

User-defined literal operator to convert to float. More...

template <char... Cs>
constexpr autooperator""_i ()

User-defined literal operator to convert to int. More...

template <char... Cs>
constexpr autooperator""_i16 ()

User-defined literal operator to convert to int16_t. More...

template <char... Cs>
constexpr autooperator""_i32 ()

User-defined literal operator to convert to int32_t. More...

template <char... Cs>
constexpr autooperator""_i64 ()

User-defined literal operator to convert to int64_t. More...

template <char... Cs>
constexpr autooperator""_i8 ()

User-defined literal operator to convert to int8_t. More...

template <char... Cs>
constexpr autooperator""_l ()

User-defined literal operator to convert to long. More...

template <char... Cs>
constexpr autooperator""_ld ()

User-defined literal operator to convert to long double. More...

template <char... Cs>
constexpr autooperator""_ll ()

User-defined literal operator to convert to long long. More...

template <char... Cs>
constexpr autooperator""_s ()

User-defined literal operator to convert to short. More...

template <char... Cs>
constexpr autooperator""_sc ()

User-defined literal operator to convert to signed char. More...

template <char... Cs>
constexpr autooperator""_u ()

User-defined literal operator to convert to unsigned. More...

template <char... Cs>
constexpr autooperator""_u16 ()

User-defined literal operator to convert to uint16_t. More...

template <char... Cs>
constexpr autooperator""_u32 ()

User-defined literal operator to convert to uint32_t. More...

template <char... Cs>
constexpr autooperator""_u64 ()

User-defined literal operator to convert to uint64_t. More...

template <char... Cs>
constexpr autooperator""_u8 ()

User-defined literal operator to convert to uint8_t. More...

template <char... Cs>
constexpr autooperator""_uc ()

User-defined literal operator to convert to unsigned char. More...

template <char... Cs>
constexpr autooperator""_ul ()

User-defined literal operator to convert to unsigned long. More...

template <char... Cs>
constexpr autooperator""_ull ()

User-defined literal operator to convert to unsigned long long. More...

template <char... Cs>
constexpr autooperator""_us ()

User-defined literal operator to convert to unsigned short. More...

Deprecated Type Wrappers Index

using_b = type_traits::value< bool >

Strongly-typed wrapper for bool values. More...

using_c = type_traits::value< char >

Strongly-typed wrapper for char values. More...

using_d = type_traits::value< double >

Strongly-typed wrapper for double values. More...

using_f = type_traits::value< float >

Strongly-typed wrapper for float values. More...

using_i = type_traits::value< int >

Strongly-typed wrapper for int values. More...

using_i16 = type_traits::value< std::int16_t >

Strongly-typed wrapper for std::int16_t values. More...

using_i32 = type_traits::value< std::int32_t >

Strongly-typed wrapper for std::int32_t values. More...

using_i64 = type_traits::value< std::int64_t >

Strongly-typed wrapper for std::int64_t values. More...

using_i8 = type_traits::value< std::int8_t >

Strongly-typed wrapper for std::int8_t values. More...

using_l = type_traits::value< long >

Strongly-typed wrapper for long values. More...

using_ld = type_traits::value< long double >

Strongly-typed wrapper for long double values. More...

using_ll = type_traits::value< long long >

Strongly-typed wrapper for long long values. More...

using_s = type_traits::value< short >

Strongly-typed wrapper for short values. More...

using_sc = type_traits::value< signed char >

Strongly-typed wrapper for signed char values. More...

using_u = type_traits::value< unsigned >

Strongly-typed wrapper for unsigned values. More...

using_u16 = type_traits::value< std::uint16_t >

Strongly-typed wrapper for std::uint16_t values. More...

using_u32 = type_traits::value< std::uint32_t >

Strongly-typed wrapper for std::uint32_t values. More...

using_u64 = type_traits::value< std::uint64_t >

Strongly-typed wrapper for std::uint64_t values. More...

using_u8 = type_traits::value< std::uint8_t >

Strongly-typed wrapper for std::uint8_t values. More...

using_uc = type_traits::value< unsigned char >

Strongly-typed wrapper for unsigned char values. More...

using_ul = type_traits::value< unsigned long >

Strongly-typed wrapper for unsigned long values. More...

using_ull = type_traits::value< unsigned long long >

Strongly-typed wrapper for unsigned long long values. More...

using_us = type_traits::value< unsigned short >

Strongly-typed wrapper for unsigned short values. More...

Type Wrappers Index

usingto_b = type_traits::value< bool >

Strongly-typed wrapper for bool values. More...

usingto_c = type_traits::value< char >

Strongly-typed wrapper for char values. More...

usingto_d = type_traits::value< double >

Strongly-typed wrapper for double values. More...

usingto_f = type_traits::value< float >

Strongly-typed wrapper for float values. More...

usingto_i = type_traits::value< int >

Strongly-typed wrapper for int values. More...

usingto_i16 = type_traits::value< std::int16_t >

Strongly-typed wrapper for std::int16_t values. More...

usingto_i32 = type_traits::value< std::int32_t >

Strongly-typed wrapper for std::int32_t values. More...

usingto_i64 = type_traits::value< std::int64_t >

Strongly-typed wrapper for std::int64_t values. More...

usingto_i8 = type_traits::value< std::int8_t >

Strongly-typed wrapper for std::int8_t values. More...

usingto_l = type_traits::value< long >

Strongly-typed wrapper for long values. More...

usingto_ld = type_traits::value< long double >

Strongly-typed wrapper for long double values. More...

usingto_ll = type_traits::value< long long >

Strongly-typed wrapper for long long values. More...

usingto_s = type_traits::value< short >

Strongly-typed wrapper for short values. More...

usingto_sc = type_traits::value< signed char >

Strongly-typed wrapper for signed char values. More...

usingto_u = type_traits::value< unsigned >

Strongly-typed wrapper for unsigned values. More...

usingto_u16 = type_traits::value< std::uint16_t >

Strongly-typed wrapper for std::uint16_t values. More...

usingto_u32 = type_traits::value< std::uint32_t >

Strongly-typed wrapper for std::uint32_t values. More...

usingto_u64 = type_traits::value< std::uint64_t >

Strongly-typed wrapper for std::uint64_t values. More...

usingto_u8 = type_traits::value< std::uint8_t >

Strongly-typed wrapper for std::uint8_t values. More...

usingto_uc = type_traits::value< unsigned char >

Strongly-typed wrapper for unsigned char values. More...

usingto_ul = type_traits::value< unsigned long >

Strongly-typed wrapper for unsigned long values. More...

usingto_ull = type_traits::value< unsigned long long >

Strongly-typed wrapper for unsigned long long values. More...

usingto_us = type_traits::value< unsigned short >

Strongly-typed wrapper for unsigned short values. More...

Description

C++ header file with declarations for the µTest++ user-defined literals and type wrappers.

This header provides the declarations for the user-defined literal operators and type wrappers used within the µTest++ framework. It defines interfaces for generating strongly-typed integral, floating-point, and boolean constants at compile time, enabling expressive and type-safe test expressions.

The declared literal operators support a wide range of C++ fundamental types, allowing constants to be suffixed with type-specific identifiers (such as _i, _u16, _f, _d, _b, etc.) to produce values that integrate seamlessly with the µTest++ comparators and reporting mechanisms.

In addition to literal operators, this header declares both deprecated and modern type wrappers for explicit type conversion, supporting enhanced clarity and type safety in test conditions. The preferred to_* forms are recommended for new code, while the older _i, _u8, etc. aliases are retained for backwards compatibility.

All definitions reside within the micro_os_plus::micro_test_plus::literals 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 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
52
53#ifndef MICRO_TEST_PLUS_LITERALS_H_
54#define MICRO_TEST_PLUS_LITERALS_H_
55
56// ----------------------------------------------------------------------------
57
58#ifdef __cplusplus
59
60// ----------------------------------------------------------------------------
61
62#include <cstdint>
63
64#include "type-traits.h"
65#include "math.h"
66
67// ----------------------------------------------------------------------------
68
69#if defined(__GNUC__)
70#pragma GCC diagnostic push
71#pragma GCC diagnostic ignored "-Waggregate-return"
72#if defined(__clang__)
73#pragma clang diagnostic ignored "-Wc++98-compat"
74#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
75#endif
76#endif
77
78// =============================================================================
79
81{
82 // --------------------------------------------------------------------------
83
109 namespace literals
110 {
121 template <char... Cs>
122 [[nodiscard]] constexpr auto
123 operator""_i ();
124
135 template <char... Cs>
136 [[nodiscard]] constexpr auto
137 operator""_s ();
138
149 template <char... Cs>
150 [[nodiscard]] constexpr auto
151 operator""_c ();
152
163 template <char... Cs>
164 [[nodiscard]] constexpr auto
165 operator""_sc ();
166
177 template <char... Cs>
178 [[nodiscard]] constexpr auto
179 operator""_l ();
180
191 template <char... Cs>
192 [[nodiscard]] constexpr auto
193 operator""_ll ();
194
205 template <char... Cs>
206 [[nodiscard]] constexpr auto
207 operator""_u ();
208
219 template <char... Cs>
220 [[nodiscard]] constexpr auto
221 operator""_uc ();
222
233 template <char... Cs>
234 [[nodiscard]] constexpr auto
235 operator""_us ();
236
247 template <char... Cs>
248 [[nodiscard]] constexpr auto
249 operator""_ul ();
250
261 template <char... Cs>
262 [[nodiscard]] constexpr auto
263 operator""_ull ();
264
275 template <char... Cs>
276 [[nodiscard]] constexpr auto
277 operator""_i8 ();
278
289 template <char... Cs>
290 [[nodiscard]] constexpr auto
291 operator""_i16 ();
292
303 template <char... Cs>
304 [[nodiscard]] constexpr auto
305 operator""_i32 ();
306
317 template <char... Cs>
318 [[nodiscard]] constexpr auto
319 operator""_i64 ();
320
331 template <char... Cs>
332 [[nodiscard]] constexpr auto
333 operator""_u8 ();
334
345 template <char... Cs>
346 [[nodiscard]] constexpr auto
347 operator""_u16 ();
348
359 template <char... Cs>
360 [[nodiscard]] constexpr auto
361 operator""_u32 ();
362
373 template <char... Cs>
374 [[nodiscard]] constexpr auto
375 operator""_u64 ();
376
387 template <char... Cs>
388 [[nodiscard]] constexpr auto
389 operator""_f ();
390
401 template <char... Cs>
402 [[nodiscard]] constexpr auto
403 operator""_d ();
404
415 template <char... Cs>
416 [[nodiscard]] constexpr auto
417 operator""_ld ();
418
428 constexpr auto
429 operator""_b (const char* name, decltype (sizeof ("")) size);
430
431 // ------------------------------------------------------------------------
432 } // namespace literals
433
434 // --------------------------------------------------------------------------
435
436#if defined(__GNUC__)
437#pragma GCC diagnostic push
438#if defined(__clang__)
439#pragma clang diagnostic ignored "-Wdocumentation-deprecated-sync"
440#endif
441#endif
442
447
464
471
478
485
492
499
506
513
520
527
534
541
548
555
562
569
576
583
590
597
604
610
616
623
640 template <class T>
642 {
648 constexpr explicit _t (const T& t);
649 };
650
651#if defined(__GNUC__)
652#pragma GCC diagnostic pop
653#endif
654
680
687
694
701
708
715
722
729
736
743
750
757
764
771
778
785
792
799
806
813
820
827
834
841
845
876 template <class T>
878 {
884 constexpr explicit to_t (const T& t);
885 };
886
887 // --------------------------------------------------------------------------
888} // namespace micro_os_plus::micro_test_plus
889
890#if defined(__GNUC__)
891#pragma GCC diagnostic pop
892#endif
893
894// ----------------------------------------------------------------------------
895
896#endif // __cplusplus
897
898// ============================================================================
899// Templates & constexpr implementations.
900
902
903// ----------------------------------------------------------------------------
904
905#endif // MICRO_TEST_PLUS_LITERALS_H_
906
907// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.