micro-test-plus 5.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
literals.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
52
53#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_LITERALS_H_
54#define MICRO_OS_PLUS_MICRO_TEST_PLUS_LITERALS_H_
55
56// ----------------------------------------------------------------------------
57
58#if defined(__cplusplus)
59
60// ----------------------------------------------------------------------------
61
62#if __has_include("micro-os-plus/project-config.h")
63#include "micro-os-plus/project-config.h"
64#endif // __has_include("micro-os-plus/project-config.h")
65
66#if __has_include("micro-os-plus/micro-test-plus-defines.h")
67#include "micro-os-plus/micro-test-plus-defines.h"
68#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
69
70#include "type-traits.h"
71#include "math.h"
72
73#include <cstdint>
74
75// ----------------------------------------------------------------------------
76
77#if defined(__GNUC__)
78#pragma GCC diagnostic push
79
80#pragma GCC diagnostic ignored "-Waggregate-return"
81#if defined(__clang__)
82#pragma clang diagnostic ignored "-Wc++98-compat"
83#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
84#endif // defined(__clang__)
85#endif // defined(__GNUC__)
86
87// =============================================================================
88
90{
91 // --------------------------------------------------------------------------
92
118 namespace literals
119 {
130 template <char... Cs>
131 [[nodiscard]] constexpr auto
132 operator""_i ();
133
144 template <char... Cs>
145 [[nodiscard]] constexpr auto
146 operator""_s ();
147
158 template <char... Cs>
159 [[nodiscard]] constexpr auto
160 operator""_c ();
161
172 template <char... Cs>
173 [[nodiscard]] constexpr auto
174 operator""_sc ();
175
186 template <char... Cs>
187 [[nodiscard]] constexpr auto
188 operator""_l ();
189
200 template <char... Cs>
201 [[nodiscard]] constexpr auto
202 operator""_ll ();
203
214 template <char... Cs>
215 [[nodiscard]] constexpr auto
216 operator""_u ();
217
228 template <char... Cs>
229 [[nodiscard]] constexpr auto
230 operator""_uc ();
231
242 template <char... Cs>
243 [[nodiscard]] constexpr auto
244 operator""_us ();
245
256 template <char... Cs>
257 [[nodiscard]] constexpr auto
258 operator""_ul ();
259
270 template <char... Cs>
271 [[nodiscard]] constexpr auto
272 operator""_ull ();
273
284 template <char... Cs>
285 [[nodiscard]] constexpr auto
286 operator""_i8 ();
287
298 template <char... Cs>
299 [[nodiscard]] constexpr auto
300 operator""_i16 ();
301
312 template <char... Cs>
313 [[nodiscard]] constexpr auto
314 operator""_i32 ();
315
326 template <char... Cs>
327 [[nodiscard]] constexpr auto
328 operator""_i64 ();
329
340 template <char... Cs>
341 [[nodiscard]] constexpr auto
342 operator""_u8 ();
343
354 template <char... Cs>
355 [[nodiscard]] constexpr auto
356 operator""_u16 ();
357
368 template <char... Cs>
369 [[nodiscard]] constexpr auto
370 operator""_u32 ();
371
382 template <char... Cs>
383 [[nodiscard]] constexpr auto
384 operator""_u64 ();
385
396 template <char... Cs>
397 [[nodiscard]] constexpr auto
398 operator""_f ();
399
410 template <char... Cs>
411 [[nodiscard]] constexpr auto
412 operator""_d ();
413
424 template <char... Cs>
425 [[nodiscard]] constexpr auto
426 operator""_ld ();
427
437 constexpr auto
438 operator""_b (const char* name, decltype (sizeof ("")) size);
439
440 // ------------------------------------------------------------------------
441 } // namespace literals
442
443 // --------------------------------------------------------------------------
444
445#if defined(__GNUC__)
446#pragma GCC diagnostic push
447
448#if defined(__clang__)
449#pragma clang diagnostic ignored "-Wdocumentation-deprecated-sync"
450#endif // defined(__clang__)
451#endif // defined(__GNUC__)
452
457
474
481
488
495
502
509
516
523
530
537
544
551
558
565
572
579
586
593
600
607
614
620
626
633
650 template <class T>
652 {
658 constexpr explicit _t (const T& t);
659 };
660
661#if defined(__GNUC__)
662#pragma GCC diagnostic pop
663#endif // defined(__GNUC__)
664
690
697
704
711
718
725
732
739
746
753
760
767
774
781
788
795
802
809
816
823
830
837
844
851
855
886 template <class T>
888 {
894 constexpr explicit to_t (const T& t);
895 };
896
897 // --------------------------------------------------------------------------
898} // namespace micro_os_plus::micro_test_plus
899
900#if defined(__GNUC__)
901#pragma GCC diagnostic pop
902#endif // defined(__GNUC__)
903
904// ----------------------------------------------------------------------------
905
906#endif // defined(__cplusplus)
907
908// ============================================================================
909// Templates, inlines & constexpr implementations.
910
912
913// ----------------------------------------------------------------------------
914
915#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_LITERALS_H_
916
917// ----------------------------------------------------------------------------
type_traits::value< std::uint16_t > _u16
Strongly-typed wrapper for std::uint16_t values.
Definition literals.h:599
type_traits::value< unsigned long long > _ull
Strongly-typed wrapper for unsigned long long values.
Definition literals.h:557
type_traits::value< short > _s
Strongly-typed wrapper for short values.
Definition literals.h:501
type_traits::value< int > _i
Strongly-typed wrapper for int values.
Definition literals.h:508
type_traits::value< short > to_s
Strongly-typed wrapper for short values.
Definition literals.h:717
type_traits::value< unsigned char > _uc
Strongly-typed wrapper for unsigned char values.
Definition literals.h:536
type_traits::value< std::int64_t > to_i64
Strongly-typed wrapper for std::int64_t values.
Definition literals.h:801
type_traits::value< std::uint8_t > _u8
Strongly-typed wrapper for std::uint8_t values.
Definition literals.h:592
type_traits::value< long double > to_ld
Strongly-typed wrapper for long double values.
Definition literals.h:850
type_traits::value< double > to_d
Strongly-typed wrapper for double values.
Definition literals.h:843
type_traits::value< std::uint32_t > to_u32
Strongly-typed wrapper for std::uint32_t values.
Definition literals.h:822
type_traits::value< float > to_f
Strongly-typed wrapper for float values.
Definition literals.h:836
type_traits::value< std::int8_t > _i8
Strongly-typed wrapper for std::int8_t values.
Definition literals.h:564
type_traits::value< unsigned long long > to_ull
Strongly-typed wrapper for unsigned long long values.
Definition literals.h:773
type_traits::value< char > to_c
Strongly-typed wrapper for char values.
Definition literals.h:703
type_traits::value< std::int32_t > _i32
Strongly-typed wrapper for std::int32_t values.
Definition literals.h:578
type_traits::value< std::uint64_t > to_u64
Strongly-typed wrapper for std::uint64_t values.
Definition literals.h:829
constexpr _t(const T &t)
Constructor for the deprecated strongly-typed wrapper.
type_traits::value< unsigned short > _us
Strongly-typed wrapper for unsigned short values.
Definition literals.h:543
type_traits::value< double > _d
Strongly-typed wrapper for double values.
Definition literals.h:625
type_traits::value< long long > _ll
Strongly-typed wrapper for long long values.
Definition literals.h:522
type_traits::value< bool > to_b
Strongly-typed wrapper for bool values.
Definition literals.h:696
type_traits::value< unsigned > _u
Strongly-typed wrapper for unsigned values.
Definition literals.h:529
type_traits::value< bool > _b
Strongly-typed wrapper for bool values.
Definition literals.h:480
type_traits::value< long double > _ld
Strongly-typed wrapper for long double values.
Definition literals.h:632
type_traits::value< std::uint8_t > to_u8
Strongly-typed wrapper for std::uint8_t values.
Definition literals.h:808
type_traits::value< unsigned char > to_uc
Strongly-typed wrapper for unsigned char values.
Definition literals.h:752
type_traits::value< std::int32_t > to_i32
Strongly-typed wrapper for std::int32_t values.
Definition literals.h:794
type_traits::value< unsigned long > _ul
Strongly-typed wrapper for unsigned long values.
Definition literals.h:550
type_traits::value< unsigned long > to_ul
Strongly-typed wrapper for unsigned long values.
Definition literals.h:766
type_traits::value< std::uint16_t > to_u16
Strongly-typed wrapper for std::uint16_t values.
Definition literals.h:815
type_traits::value< std::int8_t > to_i8
Strongly-typed wrapper for std::int8_t values.
Definition literals.h:780
constexpr to_t(const T &t)
Constructor for the strongly-typed wrapper.
type_traits::value< long > _l
Strongly-typed wrapper for long values.
Definition literals.h:515
type_traits::value< long > to_l
Strongly-typed wrapper for long values.
Definition literals.h:731
type_traits::value< int > to_i
Strongly-typed wrapper for int values.
Definition literals.h:724
type_traits::value< long long > to_ll
Strongly-typed wrapper for long long values.
Definition literals.h:738
type_traits::value< char > _c
Strongly-typed wrapper for char values.
Definition literals.h:487
type_traits::value< std::uint64_t > _u64
Strongly-typed wrapper for std::uint64_t values.
Definition literals.h:613
type_traits::value< unsigned > to_u
Strongly-typed wrapper for unsigned values.
Definition literals.h:745
type_traits::value< unsigned short > to_us
Strongly-typed wrapper for unsigned short values.
Definition literals.h:759
type_traits::value< signed char > _sc
Strongly-typed wrapper for signed char values.
Definition literals.h:494
type_traits::value< signed char > to_sc
Strongly-typed wrapper for signed char values.
Definition literals.h:710
type_traits::value< float > _f
Strongly-typed wrapper for float values.
Definition literals.h:619
type_traits::value< std::int64_t > _i64
Strongly-typed wrapper for std::int64_t values.
Definition literals.h:585
type_traits::value< std::int16_t > _i16
Strongly-typed wrapper for std::int16_t values.
Definition literals.h:571
type_traits::value< std::int16_t > to_i16
Strongly-typed wrapper for std::int16_t values.
Definition literals.h:787
type_traits::value< std::uint32_t > _u32
Strongly-typed wrapper for std::uint32_t values.
Definition literals.h:606
C++ header file with inline implementations for the µTest++ literals and type wrappers.
C++ header file with declarations for the µTest++ mathematical utilities.
User-defined literals and type wrappers for the µTest++ testing framework.
Primary namespace for the µTest++ testing framework.
Struct template representing a generic value, accessible via a getter.
C++ header file with declarations for the µTest++ type trait utilities and metaprogramming support.