micro-test-plus 4.1.0
µ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_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// ----------------------------------------------------------------------------
type_traits::value< std::uint16_t > _u16
Strongly-typed wrapper for std::uint16_t values.
Definition literals.h:589
type_traits::value< unsigned long long > _ull
Strongly-typed wrapper for unsigned long long values.
Definition literals.h:547
type_traits::value< short > _s
Strongly-typed wrapper for short values.
Definition literals.h:491
type_traits::value< int > _i
Strongly-typed wrapper for int values.
Definition literals.h:498
type_traits::value< short > to_s
Strongly-typed wrapper for short values.
Definition literals.h:707
type_traits::value< unsigned char > _uc
Strongly-typed wrapper for unsigned char values.
Definition literals.h:526
type_traits::value< std::int64_t > to_i64
Strongly-typed wrapper for std::int64_t values.
Definition literals.h:791
type_traits::value< std::uint8_t > _u8
Strongly-typed wrapper for std::uint8_t values.
Definition literals.h:582
type_traits::value< long double > to_ld
Strongly-typed wrapper for long double values.
Definition literals.h:840
type_traits::value< double > to_d
Strongly-typed wrapper for double values.
Definition literals.h:833
type_traits::value< std::uint32_t > to_u32
Strongly-typed wrapper for std::uint32_t values.
Definition literals.h:812
type_traits::value< float > to_f
Strongly-typed wrapper for float values.
Definition literals.h:826
type_traits::value< std::int8_t > _i8
Strongly-typed wrapper for std::int8_t values.
Definition literals.h:554
type_traits::value< unsigned long long > to_ull
Strongly-typed wrapper for unsigned long long values.
Definition literals.h:763
type_traits::value< char > to_c
Strongly-typed wrapper for char values.
Definition literals.h:693
type_traits::value< std::int32_t > _i32
Strongly-typed wrapper for std::int32_t values.
Definition literals.h:568
type_traits::value< std::uint64_t > to_u64
Strongly-typed wrapper for std::uint64_t values.
Definition literals.h:819
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:533
type_traits::value< double > _d
Strongly-typed wrapper for double values.
Definition literals.h:615
type_traits::value< long long > _ll
Strongly-typed wrapper for long long values.
Definition literals.h:512
type_traits::value< bool > to_b
Strongly-typed wrapper for bool values.
Definition literals.h:686
type_traits::value< unsigned > _u
Strongly-typed wrapper for unsigned values.
Definition literals.h:519
type_traits::value< bool > _b
Strongly-typed wrapper for bool values.
Definition literals.h:470
type_traits::value< long double > _ld
Strongly-typed wrapper for long double values.
Definition literals.h:622
type_traits::value< std::uint8_t > to_u8
Strongly-typed wrapper for std::uint8_t values.
Definition literals.h:798
type_traits::value< unsigned char > to_uc
Strongly-typed wrapper for unsigned char values.
Definition literals.h:742
type_traits::value< std::int32_t > to_i32
Strongly-typed wrapper for std::int32_t values.
Definition literals.h:784
type_traits::value< unsigned long > _ul
Strongly-typed wrapper for unsigned long values.
Definition literals.h:540
type_traits::value< unsigned long > to_ul
Strongly-typed wrapper for unsigned long values.
Definition literals.h:756
type_traits::value< std::uint16_t > to_u16
Strongly-typed wrapper for std::uint16_t values.
Definition literals.h:805
type_traits::value< std::int8_t > to_i8
Strongly-typed wrapper for std::int8_t values.
Definition literals.h:770
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:505
type_traits::value< long > to_l
Strongly-typed wrapper for long values.
Definition literals.h:721
type_traits::value< int > to_i
Strongly-typed wrapper for int values.
Definition literals.h:714
type_traits::value< long long > to_ll
Strongly-typed wrapper for long long values.
Definition literals.h:728
type_traits::value< char > _c
Strongly-typed wrapper for char values.
Definition literals.h:477
type_traits::value< std::uint64_t > _u64
Strongly-typed wrapper for std::uint64_t values.
Definition literals.h:603
type_traits::value< unsigned > to_u
Strongly-typed wrapper for unsigned values.
Definition literals.h:735
type_traits::value< unsigned short > to_us
Strongly-typed wrapper for unsigned short values.
Definition literals.h:749
type_traits::value< signed char > _sc
Strongly-typed wrapper for signed char values.
Definition literals.h:484
type_traits::value< signed char > to_sc
Strongly-typed wrapper for signed char values.
Definition literals.h:700
type_traits::value< float > _f
Strongly-typed wrapper for float values.
Definition literals.h:609
type_traits::value< std::int64_t > _i64
Strongly-typed wrapper for std::int64_t values.
Definition literals.h:575
type_traits::value< std::int16_t > _i16
Strongly-typed wrapper for std::int16_t values.
Definition literals.h:561
type_traits::value< std::int16_t > to_i16
Strongly-typed wrapper for std::int16_t values.
Definition literals.h:777
type_traits::value< std::uint32_t > _u32
Strongly-typed wrapper for std::uint32_t values.
Definition literals.h:596
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.