micro-test-plus 3.2.2
µ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 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any 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
9 * be 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#include "type-traits.h"
64#include "math.h"
65
66// ----------------------------------------------------------------------------
67
68#if defined(__GNUC__)
69#pragma GCC diagnostic push
70#pragma GCC diagnostic ignored "-Waggregate-return"
71#if defined(__clang__)
72#pragma clang diagnostic ignored "-Wc++98-compat"
73#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
74#endif
75#endif
76
78{
79 // --------------------------------------------------------------------------
80
106 namespace literals
107 {
118 template <char... Cs>
119 [[nodiscard]] constexpr auto
120 operator""_i ();
121
132 template <char... Cs>
133 [[nodiscard]] constexpr auto
134 operator""_s ();
135
146 template <char... Cs>
147 [[nodiscard]] constexpr auto
148 operator""_c ();
149
160 template <char... Cs>
161 [[nodiscard]] constexpr auto
162 operator""_sc ();
163
174 template <char... Cs>
175 [[nodiscard]] constexpr auto
176 operator""_l ();
177
188 template <char... Cs>
189 [[nodiscard]] constexpr auto
190 operator""_ll ();
191
202 template <char... Cs>
203 [[nodiscard]] constexpr auto
204 operator""_u ();
205
216 template <char... Cs>
217 [[nodiscard]] constexpr auto
218 operator""_uc ();
219
230 template <char... Cs>
231 [[nodiscard]] constexpr auto
232 operator""_us ();
233
244 template <char... Cs>
245 [[nodiscard]] constexpr auto
246 operator""_ul ();
247
258 template <char... Cs>
259 [[nodiscard]] constexpr auto
260 operator""_ull ();
261
272 template <char... Cs>
273 [[nodiscard]] constexpr auto
274 operator""_i8 ();
275
286 template <char... Cs>
287 [[nodiscard]] constexpr auto
288 operator""_i16 ();
289
300 template <char... Cs>
301 [[nodiscard]] constexpr auto
302 operator""_i32 ();
303
314 template <char... Cs>
315 [[nodiscard]] constexpr auto
316 operator""_i64 ();
317
329 template <char... Cs>
330 [[nodiscard]] constexpr auto
331 operator""_u8 ();
332
343 template <char... Cs>
344 [[nodiscard]] constexpr auto
345 operator""_u16 ();
346
357 template <char... Cs>
358 [[nodiscard]] constexpr auto
359 operator""_u32 ();
360
371 template <char... Cs>
372 [[nodiscard]] constexpr auto
373 operator""_u64 ();
374
385 template <char... Cs>
386 [[nodiscard]] constexpr auto
387 operator""_f ();
388
399 template <char... Cs>
400 [[nodiscard]] constexpr auto
401 operator""_d ();
402
413 template <char... Cs>
414 [[nodiscard]] constexpr auto
415 operator""_ld ();
416
426 constexpr auto
427 operator""_b (const char* name, decltype (sizeof ("")) size);
428
429 // ------------------------------------------------------------------------
430 } // namespace literals
431
432 // --------------------------------------------------------------------------
433
434#if defined(__GNUC__)
435#pragma GCC diagnostic push
436#if defined(__clang__)
437#pragma clang diagnostic ignored "-Wdocumentation-deprecated-sync"
438#endif
439#endif
440
445
462
469
476
483
490
497
504
511
518
525
532
539
546
553
560
567
574
581
588
595
602
608
614
621
638 template <class T>
640 {
650 constexpr explicit _t (const T& t) : type_traits::value<T>{ t }
651 {
652 }
653 };
654
655#if defined(__GNUC__)
656#pragma GCC diagnostic pop
657#endif
658
684
691
698
705
712
719
726
733
740
747
754
761
768
775
782
789
796
803
810
817
824
831
838
845
849
880 template <class T>
882 {
892 constexpr explicit to_t (const T& t) : type_traits::value<T>{ t }
893 {
894 }
895 };
896
897 // --------------------------------------------------------------------------
898} // namespace micro_os_plus::micro_test_plus
899
900#if defined(__GNUC__)
901#pragma GCC diagnostic pop
902#endif
903
904// ----------------------------------------------------------------------------
905
906#endif // __cplusplus
907
908// ----------------------------------------------------------------------------
909
910#endif // MICRO_TEST_PLUS_LITERALS_H_
911
912// ----------------------------------------------------------------------------
type_traits::value< std::uint16_t > _u16
Strongly-typed wrapper for std::uint16_t values.
Definition literals.h:587
type_traits::value< unsigned long long > _ull
Strongly-typed wrapper for unsigned long long values.
Definition literals.h:545
type_traits::value< short > _s
Strongly-typed wrapper for short values.
Definition literals.h:489
type_traits::value< int > _i
Strongly-typed wrapper for int values.
Definition literals.h:496
type_traits::value< short > to_s
Strongly-typed wrapper for short values.
Definition literals.h:711
type_traits::value< unsigned char > _uc
Strongly-typed wrapper for unsigned char values.
Definition literals.h:524
type_traits::value< std::int64_t > to_i64
Strongly-typed wrapper for std::int64_t values.
Definition literals.h:795
type_traits::value< std::uint8_t > _u8
Strongly-typed wrapper for std::uint8_t values.
Definition literals.h:580
type_traits::value< long double > to_ld
Strongly-typed wrapper for long double values.
Definition literals.h:844
type_traits::value< double > to_d
Strongly-typed wrapper for double values.
Definition literals.h:837
type_traits::value< std::uint32_t > to_u32
Strongly-typed wrapper for std::uint32_t values.
Definition literals.h:816
type_traits::value< float > to_f
Strongly-typed wrapper for float values.
Definition literals.h:830
type_traits::value< std::int8_t > _i8
Strongly-typed wrapper for std::int8_t values.
Definition literals.h:552
type_traits::value< unsigned long long > to_ull
Strongly-typed wrapper for unsigned long long values.
Definition literals.h:767
type_traits::value< char > to_c
Strongly-typed wrapper for char values.
Definition literals.h:697
type_traits::value< std::int32_t > _i32
Strongly-typed wrapper for std::int32_t values.
Definition literals.h:566
type_traits::value< std::uint64_t > to_u64
Strongly-typed wrapper for std::uint64_t values.
Definition literals.h:823
constexpr _t(const T &t)
Constructor for the deprecated strongly-typed wrapper.
Definition literals.h:650
type_traits::value< unsigned short > _us
Strongly-typed wrapper for unsigned short values.
Definition literals.h:531
type_traits::value< double > _d
Strongly-typed wrapper for double values.
Definition literals.h:613
type_traits::value< long long > _ll
Strongly-typed wrapper for long long values.
Definition literals.h:510
type_traits::value< bool > to_b
Strongly-typed wrapper for bool values.
Definition literals.h:690
type_traits::value< unsigned > _u
Strongly-typed wrapper for unsigned values.
Definition literals.h:517
type_traits::value< bool > _b
Strongly-typed wrapper for bool values.
Definition literals.h:468
type_traits::value< long double > _ld
Strongly-typed wrapper for long double values.
Definition literals.h:620
type_traits::value< std::uint8_t > to_u8
Strongly-typed wrapper for std::uint8_t values.
Definition literals.h:802
type_traits::value< unsigned char > to_uc
Strongly-typed wrapper for unsigned char values.
Definition literals.h:746
type_traits::value< std::int32_t > to_i32
Strongly-typed wrapper for std::int32_t values.
Definition literals.h:788
type_traits::value< unsigned long > _ul
Strongly-typed wrapper for unsigned long values.
Definition literals.h:538
type_traits::value< unsigned long > to_ul
Strongly-typed wrapper for unsigned long values.
Definition literals.h:760
type_traits::value< std::uint16_t > to_u16
Strongly-typed wrapper for std::uint16_t values.
Definition literals.h:809
type_traits::value< std::int8_t > to_i8
Strongly-typed wrapper for std::int8_t values.
Definition literals.h:774
constexpr to_t(const T &t)
Constructor for the strongly-typed wrapper.
Definition literals.h:892
type_traits::value< long > _l
Strongly-typed wrapper for long values.
Definition literals.h:503
type_traits::value< long > to_l
Strongly-typed wrapper for long values.
Definition literals.h:725
type_traits::value< int > to_i
Strongly-typed wrapper for int values.
Definition literals.h:718
type_traits::value< long long > to_ll
Strongly-typed wrapper for long long values.
Definition literals.h:732
type_traits::value< char > _c
Strongly-typed wrapper for char values.
Definition literals.h:475
type_traits::value< std::uint64_t > _u64
Strongly-typed wrapper for std::uint64_t values.
Definition literals.h:601
type_traits::value< unsigned > to_u
Strongly-typed wrapper for unsigned values.
Definition literals.h:739
type_traits::value< unsigned short > to_us
Strongly-typed wrapper for unsigned short values.
Definition literals.h:753
type_traits::value< signed char > _sc
Strongly-typed wrapper for signed char values.
Definition literals.h:482
type_traits::value< signed char > to_sc
Strongly-typed wrapper for signed char values.
Definition literals.h:704
type_traits::value< float > _f
Strongly-typed wrapper for float values.
Definition literals.h:607
type_traits::value< std::int64_t > _i64
Strongly-typed wrapper for std::int64_t values.
Definition literals.h:573
type_traits::value< std::int16_t > _i16
Strongly-typed wrapper for std::int16_t values.
Definition literals.h:559
type_traits::value< std::int16_t > to_i16
Strongly-typed wrapper for std::int16_t values.
Definition literals.h:781
type_traits::value< std::uint32_t > _u32
Strongly-typed wrapper for std::uint32_t values.
Definition literals.h:594
C++ header file with declarations for the µTest++ mathematical utilities.
User-defined literals and type wrappers for the µTest++ testing framework.
Type trait utilities and metaprogramming support for the µTest++ testing framework.
Primary namespace for the µTest++ testing framework.
Struct template representing a generic value, accessible via a getter.
constexpr value(const T &_value)
Constructs a value object with the specified value.
C++ header file with declarations for the µTest++ type trait utilities and metaprogramming support.