ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7///
8/// This header does not belong to a module of \alib, but is
9/// included in any \alibbuild.
10/// Its purposes are:
11/// - To identify given \ref GrpALibPreproSymbols related to module selection and enable
12/// corresponding symbols (that may be not given) of mandatory dependent modules.
13/// - Detect and assert C++ language version.
14/// - Define preprocessor utilities as needed throughout \alib.
15//==================================================================================================
16#ifndef INL_ALIB
17#define INL_ALIB 1
18#pragma once
19
20#define ALIB_VERSION 2510
21#define ALIB_REVISION 0
22
23#ifndef DOXYGEN
24# define DOXYGEN 0
25#endif
26
27#include <concepts>
28#include <type_traits>
29
30
31#if !DOXYGEN
32
33// #################################################################################################
34// Single-threaded library?
35// #################################################################################################
36#if !defined( ALIB_SINGLE_THREADED )
37# define ALIB_SINGLE_THREADED 0
38#endif
39#if ALIB_SINGLE_THREADED
40# define IF_ALIB_SINGLE_THREADED(...) __VA_ARGS__
41# define IFNOT_ALIB_SINGLE_THREADED(...)
42#else
43# define IF_ALIB_SINGLE_THREADED(...)
44# define IFNOT_ALIB_SINGLE_THREADED(...) __VA_ARGS__
45#endif
46
47// #################################################################################################
48// No module selection symbol given but threads? -> choose ALL
49// #################################################################################################
50#if !defined( ALIB_ALOX ) \
51 && !defined( ALIB_BITBUFFER ) \
52 && !defined( ALIB_BOXING ) \
53 && !defined( ALIB_CAMP ) \
54 && !defined( ALIB_CLI ) \
55 && !defined( ALIB_VARIABLES ) \
56 && !defined( ALIB_CONTAINERS ) \
57 && !defined( ALIB_ENUMRECORDS ) \
58 && !defined( ALIB_EXCEPTIONS ) \
59 && !defined( ALIB_EXPRESSIONS ) \
60 && !defined( ALIB_FILES ) \
61 && !defined( ALIB_FORMAT ) \
62 && !defined( ALIB_MONOMEM ) \
63 && !defined( ALIB_RESOURCES ) \
64 && !defined( ALIB_SINGLETONS ) \
65 && !defined( ALIB_STRINGS ) \
66 && !defined( ALIB_SYSTEM ) \
67 && !defined( ALIB_THREADMODEL )
68# define ALIB_ALOX 1
69# define ALIB_BITBUFFER 1
70# define ALIB_CLI 1
71# define ALIB_EXPRESSIONS 1
72# define ALIB_FILES 1
73# if !ALIB_SINGLE_THREADED
74# define ALIB_THREADMODEL 1
75# endif
76#elif defined(ALIB_THREADMODEL ) && ALIB_SINGLE_THREADED
77# error "ALib Module THREADMODEL requested, while symbol ALIB_SINGLE_THREADED is set"
78#endif
79
80#if !defined(ALIB_ALOX )
81# define ALIB_ALOX 0
82#endif
83#if !defined(ALIB_BITBUFFER )
84# define ALIB_BITBUFFER 0
85#endif
86#if !defined(ALIB_BOXING )
87# define ALIB_BOXING 0
88#endif
89#if !defined(ALIB_CLI )
90# define ALIB_CLI 0
91#endif
92#if !defined(ALIB_FORMAT )
93# define ALIB_FORMAT 0
94#endif
95#if !defined(ALIB_EXCEPTIONS )
96# define ALIB_EXCEPTIONS 0
97#endif
98#if !defined(ALIB_SYSTEM )
99# define ALIB_SYSTEM 0
100#endif
101#if !defined(ALIB_RESOURCES )
102# define ALIB_RESOURCES 0
103#endif
104#if !defined(ALIB_CONTAINERS )
105# define ALIB_CONTAINERS 0
106#endif
107#if !defined(ALIB_VARIABLES)
108# define ALIB_VARIABLES 0
109#endif
110#if !defined(ALIB_ENUMRECORDS )
111# define ALIB_ENUMRECORDS 0
112#endif
113#if !defined(ALIB_EXPRESSIONS )
114# define ALIB_EXPRESSIONS 0
115#endif
116#if !defined(ALIB_FILES )
117# define ALIB_FILES 0
118#endif
119#if !defined(ALIB_MONOMEM )
120# define ALIB_MONOMEM 0
121#endif
122#if !defined(ALIB_SINGLETONS )
123# define ALIB_SINGLETONS 0
124#endif
125#if !defined(ALIB_STRINGS )
126# define ALIB_STRINGS 0
127#endif
128#if !defined(ALIB_CAMP )
129# define ALIB_CAMP 0
130#endif
131#if !defined( ALIB_THREADMODEL )
132# define ALIB_THREADMODEL 0
133#endif
134
135// #################################################################################################
136// Resolve module dependencies
137// #################################################################################################
138#if ALIB_EXPRESSIONS
139# undef ALIB_CAMP
140# define ALIB_CAMP 1
141#endif
142#if ALIB_CLI
143# undef ALIB_CAMP
144# define ALIB_CAMP 1
145#endif
146#if ALIB_FILES
147# undef ALIB_CAMP
148# define ALIB_CAMP 1
149#endif
150#if ALIB_ALOX
151# undef ALIB_CAMP
152# define ALIB_CAMP 1
153#endif
154#if ALIB_CAMP
155# undef ALIB_FORMAT
156# define ALIB_FORMAT 1
157# undef ALIB_VARIABLES
158# define ALIB_VARIABLES 1
159#endif
160#if ALIB_VARIABLES
161# undef ALIB_CONTAINERS
162# define ALIB_CONTAINERS 1
163# undef ALIB_MONOMEM
164# define ALIB_MONOMEM 1
165# undef ALIB_SYSTEM
166# define ALIB_SYSTEM 1
167#endif
168#if ALIB_FORMAT
169# undef ALIB_EXCEPTIONS
170# define ALIB_EXCEPTIONS 1
171#endif
172#if ALIB_EXCEPTIONS
173# undef ALIB_BOXING
174# define ALIB_BOXING 1
175# undef ALIB_ENUMRECORDS
176# define ALIB_ENUMRECORDS 1
177# undef ALIB_RESOURCES
178# define ALIB_RESOURCES 1
179#endif
180#if ALIB_THREADMODEL
181# undef ALIB_BOXING
182# define ALIB_BOXING 1
183# undef ALIB_CONTAINERS
184# define ALIB_CONTAINERS 1
185# undef ALIB_MONOMEM
186# define ALIB_MONOMEM 1
187#endif
188#if ALIB_SYSTEM
189# undef ALIB_BOXING
190# define ALIB_BOXING 1
191# undef ALIB_ENUMRECORDS
192# define ALIB_ENUMRECORDS 1
193#endif
194#if ALIB_BITBUFFER
195# undef ALIB_CONTAINERS
196# define ALIB_CONTAINERS 1
197# undef ALIB_MONOMEM
198# define ALIB_MONOMEM 1
199#endif
200#if ALIB_RESOURCES
201# undef ALIB_CONTAINERS
202# define ALIB_CONTAINERS 1
203# undef ALIB_MONOMEM
204# define ALIB_MONOMEM 1
205# undef ALIB_STRINGS
206# define ALIB_STRINGS 1
207#endif
208#if ALIB_ENUMRECORDS
209# undef ALIB_SINGLETONS
210# define ALIB_SINGLETONS 1
211# undef ALIB_STRINGS
212# define ALIB_STRINGS 1
213#endif
214#if ALIB_BOXING
215# undef ALIB_SINGLETONS
216# define ALIB_SINGLETONS 1
217#endif
218
219// #################################################################################################
220// if !DOXYGEN
221// #################################################################################################
222#else
223#define ALIB_ALOX 1
224#define ALIB_BITBUFFER 1
225#define ALIB_BOXING 1
226#define ALIB_CAMP 1
227#define ALIB_FORMAT 1
228#define ALIB_EXCEPTIONS 1
229#define ALIB_SYSTEM 1
230#define ALIB_RESOURCES 1
231#define ALIB_CLI 1
232#define ALIB_VARIABLES 1
233#define ALIB_CONTAINERS 1
234#define ALIB_ENUMRECORDS 1
235#define ALIB_EXPRESSIONS 1
236#define ALIB_FILES 1
237#define ALIB_MONOMEM 1
238#define ALIB_SINGLETONS 1
239#define ALIB_STRINGS 1
240#define ALIB_THREADMODEL 1
241#endif //!DOXYGEN
242
243// #################################################################################################
244// Macros for checking availability of modules
245// #################################################################################################
246#define ALIB_DOCUMENTATION_URL "https://alib.dev/"
247
248#define ALIB_ASSERT_MODULE(modulename) \
249static_assert( ALIB_ ## modulename, \
250 "This module is not included in the ALib Build. " \
251 "See " ALIB_DOCUMENTATION_URL "alib_manual.html for more information" ); \
252
253// #################################################################################################
254// Macros to select code (without using #if/#endif)
255// #################################################################################################
256#if ALIB_ALOX
257# define IF_ALIB_ALOX(...) __VA_ARGS__
258# define IFNOT_ALIB_ALOX(...)
259#else
260# define IF_ALIB_ALOX(...)
261# define IFNOT_ALIB_ALOX(...) __VA_ARGS__
262#endif
263
264#if ALIB_BITBUFFER
265# define IF_ALIB_BITBUFFER(...) __VA_ARGS__
266# define IFNOT_ALIB_BITBUFFER(...)
267#else
268# define IF_ALIB_BITBUFFER(...)
269# define IFNOT_ALIB_BITBUFFER(...) __VA_ARGS__
270#endif
271
272#if ALIB_BOXING
273# define IF_ALIB_BOXING(...) __VA_ARGS__
274# define IFNOT_ALIB_BOXING(...)
275#else
276# define IF_ALIB_BOXING(...)
277# define IFNOT_ALIB_BOXING(...) __VA_ARGS__
278#endif
279
280#if ALIB_FORMAT
281# define IF_ALIB_FORMAT(...) __VA_ARGS__
282# define IFNOT_ALIB_FORMAT(...)
283#else
284# define IF_ALIB_FORMAT(...)
285# define IFNOT_ALIB_FORMAT(...) __VA_ARGS__
286#endif
287
288#if ALIB_EXCEPTIONS
289# define IF_ALIB_EXCEPTIONS(...) __VA_ARGS__
290# define IFNOT_ALIB_EXCEPTIONS(...)
291#else
292# define IF_ALIB_EXCEPTIONS(...)
293# define IFNOT_ALIB_EXCEPTIONS(...) __VA_ARGS__
294#endif
295
296#if ALIB_SYSTEM
297# define IF_ALIB_SYSTEM(...) __VA_ARGS__
298# define IFNOT_ALIB_SYSTEM(...)
299#else
300# define IF_ALIB_SYSTEM(...)
301# define IFNOT_ALIB_SYSTEM(...) __VA_ARGS__
302#endif
303
304#if ALIB_RESOURCES
305# define IF_ALIB_RESOURCES(...) __VA_ARGS__
306# define IFNOT_ALIB_RESOURCES(...)
307#else
308# define IF_ALIB_RESOURCES(...)
309# define IFNOT_ALIB_RESOURCES(...) __VA_ARGS__
310#endif
311
312#if ALIB_CLI
313# define IF_ALIB_CLI(...) __VA_ARGS__
314# define IFNOT_ALIB_CLI(...)
315#else
316# define IF_ALIB_CLI(...)
317# define IFNOT_ALIB_CLI(...) __VA_ARGS__
318#endif
319
320#if ALIB_VARIABLES
321# define IF_ALIB_VARIABLES(...) __VA_ARGS__
322# define IFNOT_ALIB_VARIABLES(...)
323#else
324# define IF_ALIB_VARIABLES(...)
325# define IFNOT_ALIB_VARIABLES(...) __VA_ARGS__
326#endif
327
328#if ALIB_CONTAINERS
329# define IF_ALIB_CONTAINERS(...) __VA_ARGS__
330# define IFNOT_ALIB_CONTAINERS(...)
331#else
332# define IF_ALIB_CONTAINERS(...)
333# define IFNOT_ALIB_CONTAINERS(...) __VA_ARGS__
334#endif
335
336#if ALIB_ENUMRECORDS
337# define IF_ALIB_ENUMRECORDS(...) __VA_ARGS__
338# define IFNOT_ALIB_ENUMRECORDS(...)
339#else
340# define IF_ALIB_ENUMRECORDS(...)
341# define IFNOT_ALIB_ENUMRECORDS(...) __VA_ARGS__
342#endif
343
344#if ALIB_EXPRESSIONS
345# define IF_ALIB_EXPRESSIONS(...) __VA_ARGS__
346# define IFNOT_ALIB_EXPRESSIONS(...)
347#else
348# define IF_ALIB_EXPRESSIONS(...)
349# define IFNOT_ALIB_EXPRESSIONS(...) __VA_ARGS__
350#endif
351
352#if ALIB_FILES
353# define IF_ALIB_FILES(...) __VA_ARGS__
354# define IFNOT_ALIB_FILES(...)
355#else
356# define IF_ALIB_FILES(...)
357# define IFNOT_ALIB_FILES(...) __VA_ARGS__
358#endif
359
360#if ALIB_MONOMEM
361# define IF_ALIB_MONOMEM(...) __VA_ARGS__
362# define IFNOT_ALIB_MONOMEM(...)
363#else
364# define IF_ALIB_MONOMEM(...)
365# define IFNOT_ALIB_MONOMEM(...) __VA_ARGS__
366#endif
367
368#if ALIB_SINGLETONS
369# define IF_ALIB_SINGLETONS(...) __VA_ARGS__
370# define IFNOT_ALIB_SINGLETONS(...)
371#else
372# define IF_ALIB_SINGLETONS(...)
373# define IFNOT_ALIB_SINGLETONS(...) __VA_ARGS__
374#endif
375
376#if ALIB_STRINGS
377# define IF_ALIB_STRINGS(...) __VA_ARGS__
378# define IFNOT_ALIB_STRINGS(...)
379#else
380# define IF_ALIB_STRINGS(...)
381# define IFNOT_ALIB_STRINGS(...) __VA_ARGS__
382#endif
383
384#if ALIB_CAMP
385# define IF_ALIB_CAMP(...) __VA_ARGS__
386# define IFNOT_ALIB_CAMP(...)
387#else
388# define IF_ALIB_CAMP(...)
389# define IFNOT_ALIB_CAMP(...) __VA_ARGS__
390#endif
391
392#if ALIB_THREADMODEL
393# define IF_ALIB_THREADMODEL(...) __VA_ARGS__
394# define IFNOT_ALIB_THREADMODEL(...)
395#else
396# define IF_ALIB_THREADMODEL(...)
397# define IFNOT_ALIB_THREADMODEL(...) __VA_ARGS__
398#endif
399
400#if !ALIB_SINGLE_THREADED
401# define IF_ALIB_THREADS(...) __VA_ARGS__
402# define IFNOT_ALIB_THREADS(...)
403#else
404# define IF_ALIB_THREADS(...)
405# define IFNOT_ALIB_THREADS(...) __VA_ARGS__
406#endif
407
408// #################################################################################################
409// Compiler detection and specifics
410// #################################################################################################
411#if !DOXYGEN
412 #define DOX_MARKER(marker)
413#endif
414
415// GCC Compiler detection
416#if defined(__clang__)
417#elif defined(__INTEL_COMPILER) //never tested
418#elif defined(_MSC_VER)
419#elif defined(__GNUC__)
420# define ALIB_GCC 1
421#endif
422
423
424
425// --- C++ standard: set ALIB_CPP_STANDARD ---
426
427// deduce && disallow < 20
428#if defined ( _MSC_VER )
429# if defined(_MSVC_LANG)
430# if _MSVC_LANG <= 201703L
431# error "ALib needs C++ standard 20. Wrong compilation settings given."
432# elif _MSVC_LANG == 202002L
433# define ALIB_INTERNAL_DEDUCED_CPPVER 20
434# elif _MSVC_LANG > 202002L
435# define ALIB_INTERNAL_DEDUCED_CPPVER 23
436# endif
437# endif
438
439
440#elif defined(__cplusplus)
441# if __cplusplus < 202002L
442# error "ALib needs C++20. Compilation aborted"
443# else
444# define ALIB_INTERNAL_DEDUCED_CPPVER 20
445# endif
446# if __cplusplus > 202002L
447# undef ALIB_INTERNAL_DEDUCED_CPPVER
448# define ALIB_INTERNAL_DEDUCED_CPPVER 23
449# endif
450#endif
451
452// check whether detected, given or given falsely
453#if !defined(ALIB_CPP_STANDARD)
454# if defined(ALIB_INTERNAL_DEDUCED_CPPVER)
455# define ALIB_CPP_STANDARD ALIB_INTERNAL_DEDUCED_CPPVER
456# else
457# error "Unknown compiler/toolchain. Can't deduce ALIB_CPP_STANDARD. Please provide this symbol 'manually' to the compiler."
458# endif
459#else
460# if defined(ALIB_INTERNAL_DEDUCED_CPPVER)
461# if (ALIB_CPP_STANDARD != ALIB_INTERNAL_DEDUCED_CPPVER)
462# error "ALIB_CPP_STANDARD was explicitly passed to the compiler, but does not match the language standard deduced by ALib_"
463# endif
464# elif ALIB_CPP_STANDARD < 20
465# error "ALIB_CPP_STANDARD must be set to at least 20."
466# endif
467#endif
468
469// final internal check
470#if ALIB_CPP_STANDARD < 20
471# error "Error in header. This must never happen."
472#endif
473
474// Inline code selection dependent on C++ Version
475#if ALIB_CPP_STANDARD >= 23
476# define ALIB_CPP_23(...) __VA_ARGS__
477# define ALIB_CPP_BEFORE_23(...)
478#else
479# define ALIB_CPP_23(...)
480# define ALIB_CPP_BEFORE_23(...) __VA_ARGS__
481#endif
482
483// Check if modules are enabled and define C++-module related macros
484#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
485# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
486#endif
487#if ALIB_C20_MODULES
488# define ALIB_EXPORT export
489#else
490# define ALIB_EXPORT
491#endif
492
493// Windows DLL Import/Export
494#if defined( _MSC_VER ) && !defined( ALIB_API_NO_DLL )
495 #ifdef ALIB_API_IS_DLL
496 #define ALIB_DLL __declspec(dllexport)
497 #else
498 #define ALIB_DLL __declspec(dllimport)
499 #endif
500#else
501 #define ALIB_DLL
502#endif
503
504
505// Warnings
506#if defined(ALIB_GCC)
507
508 #define ALIB_WARNINGS_UNINITIALIZED_OFF \
509 _Pragma("GCC diagnostic push") \
510 _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") \
511
512 #define ALIB_WARNINGS_ALLOW_NULL_POINTER_PASSING \
513 _Pragma("GCC diagnostic push") \
514 _Pragma("GCC diagnostic ignored \"-Wnonnull\"") \
515
516 #define ALIB_WARNINGS_ALLOW_UNREACHABLE_CODE \
517 _Pragma("GCC diagnostic push") \
518
519 #define ALIB_WARNINGS_ALLOW_MACRO_REDEFINITION \
520 _Pragma("GCC diagnostic push") \
521
522 #define ALIB_WARNINGS_ALLOW_UNSAFE_FUNCTION_OR_VARIABLE \
523 _Pragma("GCC diagnostic push") \
524
525 #define ALIB_WARNINGS_MACRO_NOT_USED_OFF \
526 _Pragma("GCC diagnostic push") \
527
528 #define ALIB_WARNINGS_RESERVED_MACRO_NAME_OFF \
529 _Pragma("GCC diagnostic push") \
530
531 #define ALIB_WARNINGS_OVERLOAD_VIRTUAL_OFF \
532 _Pragma("GCC diagnostic push") \
533
534 #define ALIB_WARNINGS_ALLOW_SPARSE_ENUM_SWITCH \
535 _Pragma("GCC diagnostic push") \
536 _Pragma("GCC diagnostic ignored \"-Wswitch\"") \
537
538 #define ALIB_WARNINGS_ALLOW_BITWISE_SWITCH \
539 _Pragma("GCC diagnostic push") \
540 _Pragma("GCC diagnostic ignored \"-Wswitch\"") \
541
542 #define ALIB_WARNINGS_ALLOW_SHIFT_COUNT_OVERFLOW \
543 _Pragma("GCC diagnostic push") \
544 _Pragma("GCC diagnostic ignored \"-Wshift-count-overflow\"") \
545
546 #define ALIB_WARNINGS_IGNORE_DEPRECATED \
547 _Pragma("GCC diagnostic push") \
548 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
549
550 #define ALIB_WARNINGS_IGNORE_UNUSED_MACRO \
551 _Pragma("GCC diagnostic push") \
552 _Pragma("GCC diagnostic ignored \"-Wunused-macros\"") \
553
554 #define ALIB_WARNINGS_IGNORE_UNUSED_PARAMETER \
555 _Pragma("GCC diagnostic push") \
556 _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \
557
558 #define ALIB_WARNINGS_IGNORE_UNUSED_VARIABLE \
559 _Pragma("GCC diagnostic push") \
560 _Pragma("GCC diagnostic ignored \"-Wunused-variable\"") \
561
562 #define ALIB_WARNINGS_IGNORE_UNUSED_FUNCTION \
563 _Pragma("GCC diagnostic push") \
564 _Pragma("GCC diagnostic ignored \"-Wunused-function\"") \
565
566 #define ALIB_WARNINGS_IGNORE_UNUSED_LAMBDA_CAPTURE \
567 _Pragma("GCC diagnostic push") \
568
569 #define ALIB_WARNINGS_IGNORE_FUNCTION_TEMPLATE \
570 _Pragma("GCC diagnostic push") \
571
572 #define ALIB_WARNINGS_IGNORE_NOTHING_RETURNED \
573 _Pragma("GCC diagnostic push") \
574 _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
575
576 #define ALIB_WARNINGS_IGNORE_INTEGRAL_CONSTANT_OVERFLOW \
577 _Pragma("GCC diagnostic push") \
578
579 #define ALIB_WARNINGS_IGNORE_RESERVED_IDENTIFIER \
580 _Pragma("GCC diagnostic push") \
581
582 #define ALIB_WARNINGS_IGNORE_DOCS \
583 _Pragma("GCC diagnostic push") \
584
585 #define ALIB_WARNINGS_IGNORE_SIGN_CONVERSION \
586 _Pragma("GCC diagnostic push") \
587 _Pragma("GCC diagnostic ignored \"-Wsign-conversion\"") \
588
589 #define ALIB_WARNINGS_IGNORE_INTEGER_OVERFLOW \
590 _Pragma("GCC diagnostic push") \
591 _Pragma("GCC diagnostic ignored \"-Wshift-count-overflow\"") \
592
593 #define ALIB_WARNINGS_RESTORE \
594 _Pragma("GCC diagnostic pop")
595
596 #if __GNUC__ < 7
597 #define ALIB_FALLTHROUGH
598 #else
599 #define ALIB_FALLTHROUGH [[gnu::fallthrough]];
600 #endif
601
602#elif defined(__clang__)
603
604 #define ALIB_WARNINGS_UNINITIALIZED_OFF \
605 _Pragma("clang diagnostic push") \
606 _Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
607 _Pragma("clang diagnostic ignored \"-Wconditional-uninitialized\"") \
608
609 #define ALIB_WARNINGS_ALLOW_NULL_POINTER_PASSING \
610 _Pragma("clang diagnostic push") \
611
612 #define ALIB_WARNINGS_ALLOW_UNREACHABLE_CODE \
613 _Pragma("clang diagnostic push") \
614 _Pragma("clang diagnostic ignored \"-Wunreachable-code\"") \
615
616 #define ALIB_WARNINGS_OVERLOAD_VIRTUAL_OFF \
617 _Pragma("clang diagnostic push") \
618 _Pragma("clang diagnostic ignored \"-Woverloaded-virtual\"") \
619
620 #define ALIB_WARNINGS_ALLOW_MACRO_REDEFINITION \
621 _Pragma("clang diagnostic push") \
622 _Pragma("clang diagnostic ignored \"-Wmacro-redefined\"") \
623
624 #define ALIB_WARNINGS_ALLOW_UNSAFE_FUNCTION_OR_VARIABLE \
625 _Pragma("clang diagnostic push") \
626 _Pragma("clang diagnostic ignored \"-Wunused-macros\"") \
627
628
629 #define ALIB_WARNINGS_MACRO_NOT_USED_OFF \
630 _Pragma("clang diagnostic push") \
631 _Pragma("clang diagnostic ignored \"-Wunused-macros\"") \
632
633 #define ALIB_WARNINGS_RESERVED_MACRO_NAME_OFF \
634 _Pragma("clang diagnostic push") \
635 _Pragma("clang diagnostic ignored \"-Wreserved-macro-identifier\"") \
636
637 #define ALIB_WARNINGS_ALLOW_SPARSE_ENUM_SWITCH \
638 _Pragma("clang diagnostic push") \
639 _Pragma("clang diagnostic ignored \"-Wswitch\"") \
640 _Pragma("clang diagnostic ignored \"-Wswitch-enum\"") \
641
642 #define ALIB_WARNINGS_ALLOW_BITWISE_SWITCH \
643 _Pragma("clang diagnostic push") \
644 _Pragma("clang diagnostic ignored \"-Wswitch\"") \
645 _Pragma("clang diagnostic ignored \"-Wcovered-switch-default\"") \
646
647 #define ALIB_WARNINGS_ALLOW_SHIFT_COUNT_OVERFLOW \
648 _Pragma("clang diagnostic push") \
649 _Pragma("clang diagnostic ignored \"-Wshift-count-overflow\"") \
650
651 #define ALIB_WARNINGS_IGNORE_DEPRECATED \
652 _Pragma("clang diagnostic push") \
653 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
654
655 #define ALIB_WARNINGS_IGNORE_UNUSED_MACRO \
656 _Pragma("clang diagnostic push") \
657 _Pragma("clang diagnostic ignored \"-Wunused-macros\"") \
658
659 #define ALIB_WARNINGS_IGNORE_UNUSED_PARAMETER \
660 _Pragma("clang diagnostic push") \
661 _Pragma("clang diagnostic ignored \"-Wunused-parameter\"") \
662
663 #define ALIB_WARNINGS_IGNORE_UNUSED_VARIABLE \
664 _Pragma("clang diagnostic push") \
665 _Pragma("clang diagnostic ignored \"-Wunused-variable\"") \
666
667 #define ALIB_WARNINGS_IGNORE_UNUSED_FUNCTION \
668 _Pragma("clang diagnostic push") \
669 _Pragma("clang diagnostic ignored \"-Wunused-function\"") \
670 _Pragma("clang diagnostic ignored \"-Wunused-member-function\"") \
671 _Pragma("clang diagnostic ignored \"-Wunused-template\"") \
672
673 #define ALIB_WARNINGS_IGNORE_UNUSED_LAMBDA_CAPTURE \
674 _Pragma("clang diagnostic push") \
675 _Pragma("clang diagnostic ignored \"-Wunused-lambda-capture\"") \
676
677 #define ALIB_WARNINGS_IGNORE_FUNCTION_TEMPLATE \
678 _Pragma("clang diagnostic push") \
679 _Pragma("clang diagnostic ignored \"-Wunused-template\"") \
680
681 #define ALIB_WARNINGS_IGNORE_NOTHING_RETURNED \
682 _Pragma("clang diagnostic push") \
683 _Pragma("clang diagnostic ignored \"-Wreturn-type\"") \
684
685 #define ALIB_WARNINGS_IGNORE_INTEGRAL_CONSTANT_OVERFLOW \
686 _Pragma("clang diagnostic push") \
687
688 #define ALIB_WARNINGS_IGNORE_DOCS \
689 _Pragma("clang diagnostic push") \
690 _Pragma("clang diagnostic ignored \"-Wdocumentation\"") \
691
692 #define ALIB_WARNINGS_IGNORE_RESERVED_IDENTIFIER \
693 _Pragma("clang diagnostic push") \
694 _Pragma("clang diagnostic ignored \"-Wreserved-identifier\"") \
695
696 #define ALIB_WARNINGS_IGNORE_INTEGER_OVERFLOW \
697 _Pragma("clang diagnostic push") \
698 _Pragma("clang diagnostic ignored \"-Winteger-overflow\"") \
699
700 #define ALIB_WARNINGS_IGNORE_SIGN_CONVERSION \
701 _Pragma("clang diagnostic push") \
702 _Pragma("clang diagnostic ignored \"-Wsign-conversion\"") \
703
704
705 #define ALIB_WARNINGS_RESTORE \
706 _Pragma("clang diagnostic pop") \
707
708 #define ALIB_FALLTHROUGH [[clang::fallthrough]];
709
710
711#elif defined(_MSC_VER)
712 #define ALIB_WARNINGS_UNINITIALIZED_OFF \
713 __pragma(warning( push )) \
714 __pragma(warning( disable : 4701 )) \
715
716 #define ALIB_WARNINGS_ALLOW_NULL_POINTER_PASSING \
717 __pragma(warning( push )) \
718
719 #define ALIB_WARNINGS_ALLOW_UNREACHABLE_CODE \
720 __pragma(warning( push )) \
721
722 #define ALIB_WARNINGS_MACRO_NOT_USED_OFF \
723 __pragma(warning( push )) \
724
725 #define ALIB_WARNINGS_RESERVED_MACRO_NAME_OFF \
726 __pragma(warning( push )) \
727
728 #define ALIB_WARNINGS_OVERLOAD_VIRTUAL_OFF \
729 __pragma(warning( push )) \
730
731 #define ALIB_WARNINGS_ALLOW_SPARSE_ENUM_SWITCH \
732 __pragma(warning( push )) \
733
734 #define ALIB_WARNINGS_ALLOW_SPARSE_ENUM_SWITCH \
735 __pragma(warning( push )) \
736
737 #define ALIB_WARNINGS_ALLOW_MACRO_REDEFINITION \
738 __pragma(warning( push )) \
739 __pragma(warning( disable : 4005 )) \
740
741 #define ALIB_WARNINGS_ALLOW_UNSAFE_FUNCTION_OR_VARIABLE \
742 __pragma(warning( push )) \
743 __pragma(warning( disable : 4996 )) \
744
745 #define ALIB_WARNINGS_ALLOW_BITWISE_SWITCH \
746 __pragma(warning( push )) \
747
748 #define ALIB_WARNINGS_ALLOW_SHIFT_COUNT_OVERFLOW \
749 __pragma(warning( push )) \
750
751 #define ALIB_WARNINGS_IGNORE_DEPRECATED \
752 __pragma(warning( push )) \
753
754 #define ALIB_WARNINGS_IGNORE_UNUSED_MACRO \
755 __pragma(warning( push )) \
756
757 #define ALIB_WARNINGS_IGNORE_UNUSED_PARAMETER \
758 __pragma(warning( push )) \
759
760 #define ALIB_WARNINGS_IGNORE_UNUSED_VARIABLE \
761 __pragma(warning( push )) \
762
763 #define ALIB_WARNINGS_IGNORE_UNUSED_FUNCTION \
764 __pragma(warning( push )) \
765
766 #define ALIB_WARNINGS_IGNORE_UNUSED_LAMBDA_CAPTURE \
767 __pragma(warning( push )) \
768
769 #define ALIB_WARNINGS_IGNORE_FUNCTION_TEMPLATE \
770 __pragma(warning( push )) \
771
772 #define ALIB_WARNINGS_IGNORE_NOTHING_RETURNED \
773 __pragma(warning( push )) \
774 __pragma(warning( disable : 4715 )) \
775
776 #define ALIB_WARNINGS_IGNORE_INTEGRAL_CONSTANT_OVERFLOW \
777 __pragma(warning( push )) \
778 __pragma(warning( disable : 4305 )) \
779 __pragma(warning( disable : 4307 )) \
780 __pragma(warning( disable : 4309 )) \
781 __pragma(warning( disable : 4310 )) \
782 __pragma(warning( disable : 4293 )) \
783
784 #define ALIB_WARNINGS_IGNORE_INTEGER_OVERFLOW \
785 __pragma(warning( push )) \
786 __pragma(warning( disable : 4293 )) \
787
788 #define ALIB_WARNINGS_IGNORE_RESERVED_IDENTIFIER \
789 __pragma(warning( push )) \
790
791 #define ALIB_WARNINGS_IGNORE_DOCS \
792 __pragma(warning( push )) \
793
794 #define ALIB_WARNINGS_IGNORE_SIGN_CONVERSION \
795 __pragma(warning( push )) \
796
797 #define ALIB_WARNINGS_IGNORE_DOCS \
798 __pragma(warning( push )) \
799
800 #define ALIB_WARNINGS_RESTORE \
801 __pragma(warning( pop )) \
802
803 #define ALIB_FALLTHROUGH
804
805#else
806 #define ALIB_WARNINGS_RESTORE
807 #define ALIB_FALLTHROUGH
808#endif
809
810// #################################################################################################
811// Availability of external libraries
812// #################################################################################################
813#if !defined(ALIB_EXT_LIB_THREADS_AVAILABLE)
814# define ALIB_EXT_LIB_THREADS_AVAILABLE 1
815#endif
816#if ALIB_EXT_LIB_THREADS_AVAILABLE
817# include <thread>
818#endif
819
820#if !defined(ALIB_FEAT_BOOST_REGEX)
821# define ALIB_FEAT_BOOST_REGEX 0
822#endif
823
824// #################################################################################################
825// Debug or release compilation
826// #################################################################################################
827#if !defined(ALIB_DEBUG)
828# if !defined(NDEBUG) || defined(_DEBUG) || defined(DEBUG)
829# define ALIB_DEBUG 1
830# else
831# define ALIB_DEBUG 0
832# endif
833#endif
834
835#if ALIB_DEBUG
836 #define ALIB_DBG(...) __VA_ARGS__
837 #define ALIB_REL(...)
838 #define ALIB_REL_DBG(releaseCode, ...) __VA_ARGS__
839#else
840 #define ALIB_DBG(...)
841 #define ALIB_REL(...) __VA_ARGS__
842 #define ALIB_REL_DBG(releaseCode, ...) releaseCode
843#endif
844
845
846
847// #################################################################################################
848// ALib Feature detection
849// (Note: this has to be done outside the module code, because the features are used with
850// the compilation verification flags below)
851// #################################################################################################
852
853// ALIB_CHARACTERS_WIDE, ALIB_SIZEOF_WCHAR_T
854#if defined(__WCHAR_MAX__)
855 #if __WCHAR_MAX__ == 0x7FFFFFFF \
856 || __WCHAR_MAX__ == 0xFFFFFFFF
857 #define ALIB_SIZEOF_WCHAR_T 4
858 #else
859 #define ALIB_SIZEOF_WCHAR_T 2
860 #endif
861#elif defined(_MSC_VER)
862 #define ALIB_SIZEOF_WCHAR_T 2
863#else
864# define ALIB_SIZEOF_WCHAR_T 4 // guessing, will be checked below
865#endif
866
867static_assert( sizeof(wchar_t) == ALIB_SIZEOF_WCHAR_T, "Error: Platform not supported" );
868
869#if !defined(ALIB_CHARACTERS_WIDE)
870# if defined(_MSC_VER)
871# define ALIB_CHARACTERS_WIDE 1
872# else
873# define ALIB_CHARACTERS_WIDE 0
874# endif
875#endif
876
877#if !defined(ALIB_CHARACTERS_SIZEOF_WCHAR)
878# define ALIB_CHARACTERS_SIZEOF_WCHAR ALIB_SIZEOF_WCHAR_T
879#elif (ALIB_CHARACTERS_SIZEOF_WCHAR != 2) && (ALIB_CHARACTERS_SIZEOF_WCHAR != 4 )
880# error "Illegal value for symbol ALIB_CHARACTERS_SIZEOF_WCHAR given. Allowed is 2 or 4."
881#endif
882
883// ALIB_DEBUG_CRITICAL_SECTIONS
884#if !defined(ALIB_DEBUG_CRITICAL_SECTIONS)
885# define ALIB_DEBUG_CRITICAL_SECTIONS 0
886#elif !ALIB_DEBUG && ALIB_DEBUG_CRITICAL_SECTIONS
887# undef ALIB_DEBUG_CRITICAL_SECTIONS
888# define ALIB_DEBUG_CRITICAL_SECTIONS 0
889# pragma message "Symbol ALIB_DEBUG_CRITICAL_SECTIONS set (from outside!) while ALIB_DEBUG is not. The symbol got disabled."
890#elif ALIB_SINGLE_THREADED && ALIB_DEBUG_CRITICAL_SECTIONS
891# undef ALIB_DEBUG_CRITICAL_SECTIONS
892# define ALIB_DEBUG_CRITICAL_SECTIONS 0
893# pragma message "Symbol ALIB_DEBUG_CRITICAL_SECTIONS set (from outside!) while symbol ALIB_SINGLE_THREADED is set in the ALib Build. The symbol got disabled."
894#endif
895
896// ALIB_DEBUG_ALLOCATIONS
897#if !defined(ALIB_DEBUG_ALLOCATIONS)
898# define ALIB_DEBUG_ALLOCATIONS 0
899#elif !ALIB_DEBUG && ALIB_DEBUG_ALLOCATIONS
900# undef ALIB_DEBUG_ALLOCATIONS
901# define ALIB_DEBUG_ALLOCATIONS 0
902# pragma message "Symbol ALIB_DEBUG_ALLOCATIONS set (from outside!) while ALIB_DEBUG is not. The symbol got disabled."
903#endif
904
905// ALIB_DEBUG_MEMORY
906#if !defined(ALIB_DEBUG_MEMORY)
907# define ALIB_DEBUG_MEMORY 0
908#elif !ALIB_DEBUG && ALIB_DEBUG_MEMORY
909# undef ALIB_DEBUG_MEMORY
910# define ALIB_DEBUG_MEMORY 0
911# pragma message "Symbol ALIB_DEBUG_MEMORY set (from outside!) while ALIB_DEBUG is not. The symbol got disabled."
912#endif
913
914
915// #################################################################################################
916// Preprocessor tools
917// #################################################################################################
918#if DOXYGEN
919# define ALIB_NSTRINGIFY(a)
920# define ALIB_STRINGIFY(a)
921#else
922# define ALIB_STRINGIFY_X(a) A_CHAR( #a )
923# define ALIB_STRINGIFY(a) ALIB_STRINGIFY_X(a)
924# define ALIB_NSTRINGIFY_X(a) #a
925# define ALIB_NSTRINGIFY(a) ALIB_NSTRINGIFY_X(a)
926#endif
927
928// Note: The double expansion ensures that if another macro is given, e.g., "__LINE__", it is
929// expanded before it is concatenated.
930#if !DOXYGEN
931#define ALIB_CONCAT_IMPL(a,b) a ## b
932#endif
933#define ALIB_CONCAT(a,b) ALIB_CONCAT_IMPL(a,b)
934
935#if defined(__clang__)
936# define ALIB_IDENTIFIER(prefix) ALIB_WARNINGS_IGNORE_RESERVED_IDENTIFIER \
937 ALIB_CONCAT(prefix, __LINE__) \
938 ALIB_WARNINGS_RESTORE
939#else
940# define ALIB_IDENTIFIER(prefix) ALIB_CONCAT(prefix, __LINE__)
941#endif
942
943#define ALIB_EMPTY
944
945
946#define ALIB_COMMA ,
947#if ALIB_DEBUG
948# define ALIB_COMMA_DBG ,
949#else
950# define ALIB_COMMA_DBG
951#endif
952
953// Macros for writing "nicer" static_assert messages
954#define ALIB_STATIC_ASSERT( CondVariable, Cond, Message ) \
955{ constexpr bool CondVariable= Cond; \
956 static_assert( CondVariable, Message ); } \
957
958#define ALIB_STATIC_DENY( CondVariable, Cond, Message ) \
959{ constexpr bool CondVariable= !(Cond); \
960 static_assert( CondVariable, Message ); } \
961
962//==================================================================================================
963/// Used with macro \ref ALIB_ASSERT_GLOBAL_NAMESPACE for testing.
964//==================================================================================================
965struct ALibTestGlobalNamespace;
966#define ALIB_ASSERT_GLOBAL_NAMESPACE \
967struct ALibTestGlobalNamespace; \
968static_assert(std::is_same<ALibTestGlobalNamespace, ::ALibTestGlobalNamespace>::value, \
969 "This is not the global namespace!");
970
971
972// #################################################################################################
973// Other tools
974// #################################################################################################
975#define ALIB_STACK_ALLOCATED_TYPE(T) \
976private: void* operator new (size_t); \
977 void* operator new (size_t, void*); \
978 void* operator new[](size_t); \
979 void* operator new[](size_t, void*); \
980 T(const T& ); \
981 T( T&& ); \
982 void operator=(const T& ); \
983 void operator=( T&& );
984
985// Template tool macros
986#define ALIB_TVALUE(T) std::remove_cv_t<std::remove_pointer_t<std::remove_reference_t<T>>>
987
988#define ALIB_HAS_METHOD(T,Method,...) \
989 !std::same_as< lang::UnknownTag, decltype(std::declval<T>(). Method( __VA_ARGS__ ))>
990
991
992
993// Macros for passing source code information
994#if defined ( _MSC_VER )
995# define ALIB_CALLER_FUNC __FUNCTION__
996#else
997# define ALIB_CALLER_FUNC __func__
998#endif
999
1000#if ALIB_EXT_LIB_THREADS_AVAILABLE
1001# define ALIB_CALLER {__FILE__,__LINE__,ALIB_CALLER_FUNC,::std::this_thread::get_id(),&typeid(*this)}
1002#else
1003# define ALIB_CALLER {__FILE__,__LINE__,ALIB_CALLER_FUNC,&typeid(*this)}
1004#endif
1005
1006#if ALIB_DEBUG
1007# define ALIB_CALLER_PRUNED ALIB_CALLER
1008# define ALIB_COMMA_CALLER_PRUNED , ALIB_CALLER
1009# define ALIB_CALLER_PRUNED_COMMA ALIB_CALLER ,
1010# define ALIB_CALLER_NULLED ALIB_CALLER
1011# define ALIB_COMMA_CALLER_NULLED , ALIB_CALLER
1012# define ALIB_CALLER_NULLED_COMMA ALIB_CALLER ,
1013# define ALIB_DBG_TAKE_CI const CallerInfo& ci
1014#else
1015# define ALIB_CALLER_PRUNED
1016# define ALIB_COMMA_CALLER_PRUNED
1017# define ALIB_CALLER_PRUNED_COMMA
1018# if ALIB_EXT_LIB_THREADS_AVAILABLE
1019# define ALIB_CALLER_NULLED {nullptr,0,nullptr,::std::thread::id(), nullptr}
1020# define ALIB_COMMA_CALLER_NULLED , {nullptr,0,nullptr,::std::thread::id(), nullptr}
1021# define ALIB_CALLER_NULLED_COMMA {nullptr,0,nullptr,::std::thread::id(), nullptr} ,
1022# else
1023# define ALIB_CALLER_NULLED {nullptr,0,nullptr,nullptr}
1024# define ALIB_COMMA_CALLER_NULLED , {nullptr,0,nullptr,nullptr}
1025# define ALIB_CALLER_NULLED_COMMA {nullptr,0,nullptr,nullptr} ,
1026# endif
1027# define ALIB_DBG_TAKE_CI
1028#endif
1029
1030// #################################################################################################
1031// Debug Messages and Assertions
1032// #################################################################################################
1033#if ALIB_DEBUG
1034# if !defined(ALIB_DEBUG_ASSERTION_PRINTABLES)
1035# define ALIB_DEBUG_ASSERTION_PRINTABLES 0
1036# endif
1037# if !DOXYGEN
1038# if ALIB_DEBUG_ASSERTION_PRINTABLES
1039# define ALIB_DEBUG_ASSERTION_PRINTABLES_DO(...) alib::assert::CheckArgs(ALIB_CALLER_PRUNED, __VA_ARGS__);
1040# else
1041# define ALIB_DEBUG_ASSERTION_PRINTABLES_DO(...)
1042# endif
1043# endif
1044
1045# define ALIB_ERROR( domain, ...) { ALIB_DEBUG_ASSERTION_PRINTABLES_DO(__VA_ARGS__) alib::assert::Raise( ALIB_CALLER_PRUNED, 0, domain, __VA_ARGS__ ); }
1046# define ALIB_WARNING( domain, ...) { ALIB_DEBUG_ASSERTION_PRINTABLES_DO(__VA_ARGS__) alib::assert::Raise( ALIB_CALLER_PRUNED, 1, domain, __VA_ARGS__ ); }
1047# define ALIB_MESSAGE( domain, ...) { ALIB_DEBUG_ASSERTION_PRINTABLES_DO(__VA_ARGS__) alib::assert::Raise( ALIB_CALLER_PRUNED, 2, domain, __VA_ARGS__ ); }
1048# define ALIB_ASSERT(cond, domain) { if( !( cond)) ALIB_ERROR( domain, "Assertion Failed" ); }
1049# define ALIB_ASSERT_ERROR( cond, domain, ...) { ALIB_DEBUG_ASSERTION_PRINTABLES_DO(__VA_ARGS__) if( !( cond)) ALIB_ERROR( domain, __VA_ARGS__ ) }
1050# define ALIB_ASSERT_WARNING( cond, domain, ...) { ALIB_DEBUG_ASSERTION_PRINTABLES_DO(__VA_ARGS__) if( !( cond)) ALIB_WARNING( domain, __VA_ARGS__ ) }
1051# define ALIB_ASSERT_MESSAGE( cond, domain, ...) { ALIB_DEBUG_ASSERTION_PRINTABLES_DO(__VA_ARGS__) if( !( cond)) ALIB_MESSAGE( domain, __VA_ARGS__ ) }
1052
1053#else // ALIB_DEBUG
1054 #define ALIB_ERROR( ... ) {}
1055 #define ALIB_WARNING( ... ) {}
1056 #define ALIB_MESSAGE( ... ) {}
1057 #define ALIB_ASSERT( ... ) {}
1058 #define ALIB_ASSERT_ERROR( ...) {}
1059 #define ALIB_ASSERT_WARNING(...) {}
1060 #define ALIB_ASSERT_MESSAGE(...) {}
1061#endif
1062
1063
1064#if ALIB_DEBUG
1065# include <assert.h>
1066 #define ALIB_ASSERT_RESULT_EQUALS( func, value ) { auto result= func; assert(result == value); ((void) result); }
1067 #define ALIB_ASSERT_RESULT_NOT_EQUALS( func, value ) { auto result= func; assert(result != value); ((void) result); }
1068 #define ALIB_ASSERT_RESULT_GREATER_THAN(func, value ) { auto result= func; assert(result > value); ((void) result); }
1069 #define ALIB_ASSERT_RESULT_LESS_THAN( func, value ) { auto result= func; assert(result < value); ((void) result); }
1070#else
1071 #define ALIB_ASSERT_RESULT_EQUALS( func, value ) { func; }
1072 #define ALIB_ASSERT_RESULT_NOT_EQUALS( func, value ) { func; }
1073 #define ALIB_ASSERT_RESULT_GREATER_THAN(func, value ) { func; }
1074 #define ALIB_ASSERT_RESULT_LESS_THAN( func, value ) { func; }
1075#endif
1076
1077// #################################################################################################
1078// Symbols introduced by lang::integer, and similar basics
1079// #################################################################################################
1080//------------- One of the 5 symbols given from outside? ---------------------
1081#if defined(ALIB_SIZEOF_INTEGER ) \
1082 || defined(ALIB_SIZEOF_INTGAP ) \
1083 || defined(ALIB_INTGAP_TYPE ) \
1084 || defined(ALIB_SIZEOF_LONGDOUBLE_REPORTED) \
1085 || defined(ALIB_SIZEOF_LONGDOUBLE_WRITTEN)
1086
1087 // just check if all are given, that's it for now
1088 #if !defined(ALIB_SIZEOF_INTEGER) \
1089 || !defined(ALIB_SIZEOF_INTGAP) \
1090 || !defined(ALIB_INTGAP_TYPE) \
1091 || !defined(ALIB_SIZEOF_LONGDOUBLE_REPORTED) \
1092 || !defined(ALIB_SIZEOF_LONGDOUBLE_WRITTEN)
1093
1094 #error "If one of the Compiler Symbols \
1095'ALIB_SIZEOF_INTEGER', \
1096'ALIB_SIZEOF_INTGAP', \
1097'ALIB_INTGAP_TYPE', \
1098'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
1099'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
1100is given (instead of letting ALib detect them), then the whole group has to be given!"
1101 #endif
1102
1103
1104//------------- None of the 5 symbols given from outside: Platform detection ---------------------
1105#else
1106
1107 // 64-Bit platforms
1108 #if (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8 ) || defined(_WIN64)
1109
1110 #define ALIB_SIZEOF_INTEGER 8
1111
1112 #if defined(_WIN32)
1113 #define ALIB_INTGAP_TYPE long;
1114 #define ALIB_SIZEOF_INTGAP 4
1115
1116 #elif defined(__APPLE__)
1117 #define ALIB_INTGAP_TYPE long;
1118 #define ALIB_SIZEOF_INTGAP 8
1119
1120 #elif defined(__GNUC__) || defined(__clang__)
1121 #define ALIB_INTGAP_TYPE long long;
1122 #define ALIB_SIZEOF_INTGAP 8
1123 #else
1124 # error "Cannot detect compilation platform. Please provide Symbols \
1125'ALIB_SIZEOF_INTEGER', \
1126'ALIB_SIZEOF_INTGAP', \
1127'ALIB_INTGAP_TYPE', \
1128'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
1129'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
1130as documented with ALib User Manual at https://alib.dev"
1131
1132 #endif
1133
1134 #if defined(_MSC_VER) || defined(__APPLE__)
1135 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 8
1136 #else
1137 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 16
1138 #endif
1139
1140 // 32-Bit platforms
1141 #elif (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4 ) || defined(_WIN32) || defined( __arm__)
1142
1143 #define ALIB_SIZEOF_INTEGER 4
1144
1145 #if defined(__APPLE__)
1146 #define ALIB_INTGAP_TYPE long;
1147 #define ALIB_SIZEOF_INTGAP 4
1148
1149 #elif defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
1150 #define ALIB_INTGAP_TYPE long;
1151 #define ALIB_SIZEOF_INTGAP 4
1152 #else
1153 #error "Cannot detect compilation platform. Please provide Symbols \
1154'ALIB_SIZEOF_INTEGER', \
1155'ALIB_SIZEOF_INTGAP', \
1156'ALIB_INTGAP_TYPE', \
1157'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
1158'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
1159as documented with ALib User Manual at https://alib.dev"
1160
1161 #endif
1162
1163 #if defined(_MSC_VER) || defined( __arm__)
1164 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 8
1165 #elif defined(__APPLE__)
1166 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 16
1167 #else
1168 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 12
1169 #endif
1170
1171 // unrecognized platform
1172 #else
1173 #error "Cannot detect compilation platform. Please provide Symbols \
1174'ALIB_SIZEOF_INTEGER', \
1175'ALIB_SIZEOF_INTGAP', \
1176'ALIB_INTGAP_TYPE', \
1177'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
1178'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
1179as documented with ALib User Manual at https://alib.dev"
1180
1181 #endif //64, 32, unrecognized
1182
1183 // deduct stuff
1184 #if (ALIB_SIZEOF_LONGDOUBLE_REPORTED == 8)
1185 # define ALIB_SIZEOF_LONGDOUBLE_WRITTEN 8
1186 #elif defined(__aarch64__)
1187 # define ALIB_SIZEOF_LONGDOUBLE_WRITTEN 16
1188 #else
1189 # define ALIB_SIZEOF_LONGDOUBLE_WRITTEN 10
1190 #endif
1191#endif
1192
1193// #################################################################################################
1194// Symbols introduced by alib::characters
1195// #################################################################################################
1196#if defined(ALIB_CHARACTERS_NATIVE_WCHAR)
1197# error "Preprocessor symbol ALIB_CHARACTERS_NATIVE_WCHAR must not be passed to the compiler. It is deduced in ALib headers."
1198#endif
1199
1200#if !DOXYGEN // strangely needed for doxygen
1201#define A_NCHAR(STR) STR
1202#if ALIB_CHARACTERS_SIZEOF_WCHAR == ALIB_SIZEOF_WCHAR_T
1203
1204 # define ALIB_CHARACTERS_NATIVE_WCHAR 1
1205 # if ALIB_CHARACTERS_SIZEOF_WCHAR == 2
1206 #define A_WCHAR(STR) L ## STR
1207 #define A_XCHAR(STR) U ## STR
1208 #define A_SCHAR(STR) U ## STR
1209 # else
1210 #define A_WCHAR(STR) L ## STR
1211 #define A_XCHAR(STR) u ## STR
1212 #define A_SCHAR(STR) u ## STR
1213 # endif
1214
1215 #else
1216
1217 # define ALIB_CHARACTERS_NATIVE_WCHAR 0
1218
1219 # if ALIB_CHARACTERS_SIZEOF_WCHAR == 2
1220 #define A_WCHAR(STR) u ## STR
1221 #define A_XCHAR(STR) L ## STR
1222 #define A_SCHAR(STR) L ## STR
1223 # else
1224 #define A_WCHAR(STR) U ## STR
1225 #define A_XCHAR(STR) L ## STR
1226 #define A_SCHAR(STR) L ## STR
1227 # endif
1228#endif
1229#endif
1230
1231#if !DOXYGEN // strangely needed for doxygen
1232#if !ALIB_CHARACTERS_WIDE
1233 #define A_CHAR(STR) STR
1234 #define A_CCHAR(STR) A_WCHAR(STR)
1235 #define ALIB_CHAR_TYPE_ID_CHARACTER 1
1236 #define ALIB_CHAR_TYPE_ID_COMPLEMENT 2
1237 #define ALIB_CHAR_TYPE_ID_STRANGE 3
1238#else
1239 #define A_CHAR(STR) A_WCHAR(STR)
1240 #define A_CCHAR(STR) STR
1241
1242 #define ALIB_CHAR_TYPE_ID_CHARACTER 2
1243 #define ALIB_CHAR_TYPE_ID_COMPLEMENT 1
1244 #define ALIB_CHAR_TYPE_ID_STRANGE 3
1245#endif
1246#endif
1247
1248#define ALIB_CHAR_TYPE_ID_N 1
1249#define ALIB_CHAR_TYPE_ID_W 2
1250#define ALIB_CHAR_TYPE_ID_X 3
1251
1252
1253//##################### Helper macros to specialize ArrayTraits/ZTArrayTraits ####################
1254#if !DOXYGEN
1255#define ALIB_CHARACTER_ARRAY_internal( PREFIX, T, TChar, Const, pAccess, pConstruction) \
1256template<> struct PREFIX ## ArrayTraits<T, TChar> { \
1257 static constexpr Policy Access= Policy:: pAccess; \
1258 static constexpr Policy Construction= Policy:: pConstruction; \
1259 static inline const TChar* Buffer( T Const & src ); \
1260 static inline integer Length( T Const & src ); \
1261 static inline T Construct( const TChar* array, integer length ); \
1262};
1263#endif
1264
1265#define ALIB_CHARACTER_ARRAY( T, TChar, Access , Construction ) \
1266ALIB_CHARACTER_ARRAY_internal( , T, TChar, const, Access , Construction )
1267
1268#define ALIB_CHARACTER_ARRAY_MUTABLE( T, TChar, Construction ) \
1269ALIB_CHARACTER_ARRAY_internal( , T, TChar, , MutableOnly, Construction )
1270
1271#define ALIB_CHARACTER_ZT_ARRAY( T, TChar, Access , Construction ) \
1272ALIB_CHARACTER_ARRAY_internal( ZT, T, TChar, const, Access , Construction )
1273
1274#define ALIB_CHARACTER_ZT_ARRAY_MUTABLE( T, TChar, Construction ) \
1275ALIB_CHARACTER_ARRAY_internal( ZT, T, TChar, , MutableOnly, Construction )
1276
1277
1278
1279#define ALIB_CHARACTER_ARRAY_IMPL_BUFFER( T, TChar, ... ) \
1280const TChar* ArrayTraits<T,TChar>::Buffer(T const& src ) { __VA_ARGS__ }
1281
1282#define ALIB_CHARACTER_ARRAY_IMPL_LENGTH( T, TChar, ... ) \
1283integer ArrayTraits<T,TChar>::Length(T const& src ) { __VA_ARGS__ }
1284
1285#define ALIB_CHARACTER_ARRAY_IMPL_BUFFER_MUTABLE( T, TChar, ... ) \
1286const TChar* ArrayTraits<T,TChar>::Buffer(T & src ) { __VA_ARGS__ }
1287
1288#define ALIB_CHARACTER_ARRAY_IMPL_LENGTH_MUTABLE( T, TChar, ... ) \
1289integer ArrayTraits<T,TChar>::Length(T & src ) { __VA_ARGS__ }
1290
1291#define ALIB_CHARACTER_ARRAY_IMPL_CONSTRUCT( T, TChar, ... ) \
1292 T ArrayTraits <T,TChar>::Construct( const TChar* array, integer length ) { __VA_ARGS__ }
1293
1294#define ALIB_CHARACTER_ZT_ARRAY_IMPL_BUFFER( T, TChar, ... ) \
1295const TChar* ZTArrayTraits<T,TChar>::Buffer( T const& src ) { __VA_ARGS__ }
1296
1297#define ALIB_CHARACTER_ZT_ARRAY_IMPL_LENGTH( T, TChar, ... ) \
1298integer ZTArrayTraits<T,TChar>::Length( T const& src ) { __VA_ARGS__ }
1299
1300#define ALIB_CHARACTER_ZT_ARRAY_IMPL_BUFFER_MUTABLE(T, TChar, ... ) \
1301const TChar* ZTArrayTraits<T,TChar>::Buffer( T & src ) { __VA_ARGS__ }
1302
1303#define ALIB_CHARACTER_ZT_ARRAY_IMPL_LENGTH_MUTABLE(T, TChar, ... ) \
1304integer ZTArrayTraits<T,TChar>::Length( T & src ) { __VA_ARGS__ }
1305
1306#define ALIB_CHARACTER_ZT_ARRAY_IMPL_CONSTRUCT( T, TChar, ... ) \
1307 T ZTArrayTraits<T,TChar>::Construct( const TChar* array, integer length ) { __VA_ARGS__ }
1308
1309
1310// #################################################################################################
1311// Symbols introduced by lang::Owner
1312// #################################################################################################
1313#define ALIB_OWN( ownable) alib::lang::Owner <decltype(ownable)> ALIB_IDENTIFIER(owner) (ownable ALIB_COMMA_CALLER_PRUNED);
1314#define ALIB_OWN_RECURSIVE(ownable) alib::lang::OwnerRecursive<decltype(ownable)> ALIB_IDENTIFIER(owner) (ownable ALIB_COMMA_CALLER_PRUNED);
1315#define ALIB_OWN_SHARED( ownable) alib::lang::OwnerShared <decltype(ownable)> ALIB_IDENTIFIER(owner) (ownable ALIB_COMMA_CALLER_PRUNED);
1316
1317// Thread-related aliases (placed here to achieve code agnostic from availability of module Threads)
1318#if !ALIB_SINGLE_THREADED
1319# define ALIB_LOCK ALIB_OWN(*this)
1320# define ALIB_LOCK_RECURSIVE ALIB_OWN_RECURSIVE(*this)
1321# define ALIB_LOCK_SHARED ALIB_OWN_SHARED(*this)
1322# define ALIB_LOCK_WITH(lock) ALIB_OWN(lock)
1323# define ALIB_LOCK_RECURSIVE_WITH(lock) ALIB_OWN_RECURSIVE(lock)
1324# define ALIB_LOCK_SHARED_WITH(lock) ALIB_OWN_SHARED(lock)
1325#else
1326# if ALIB_DEBUG
1327# define ALIB_LOCK { alib::assert::SingleThreaded(); }
1328# define ALIB_LOCK_RECURSIVE { alib::assert::SingleThreaded(); }
1329# define ALIB_LOCK_SHARED { alib::assert::SingleThreaded(); }
1330# define ALIB_LOCK_WITH(VOID) { alib::assert::SingleThreaded(); }
1331# define ALIB_LOCK_RECURSIVE_WITH(VOID) { alib::assert::SingleThreaded(); }
1332# define ALIB_LOCK_SHARED_WITH(VOID) { alib::assert::SingleThreaded(); }
1333# else
1334# define ALIB_LOCK {}
1335# define ALIB_LOCK_RECURSIVE {}
1336# define ALIB_LOCK_SHARED {}
1337# define ALIB_LOCK_WITH(VOID) {}
1338# define ALIB_LOCK_RECURSIVE_WITH(VOID) {}
1339# define ALIB_LOCK_SHARED_WITH(VOID) {}
1340# endif
1341#endif // ALIB_SINGLE_THREADED
1342
1343
1344// Recursive invocation detection
1345#if ALIB_DEBUG
1346#define ALIB_DBG_PREVENT_RECURSIVE_METHOD_CALLS_MEMBER_DECL \
1347bool dbgRecursionDetectionFlag = false;
1348
1349#define ALIB_DBG_PREVENT_RECURSIVE_METHOD_CALLS \
1350struct RecursionDetection \
1351{ \
1352 bool& TestMember; \
1353 RecursionDetection( bool& testMember ) : TestMember(testMember) {} \
1354 \
1355 void Acquire( const lang::CallerInfo& ci ) \
1356 { \
1357 ALIB_ASSERT_ERROR(TestMember==false,"FSOWNER","Forbidden recursive use of method ", ci.Func)\
1358 TestMember= true; \
1359 } \
1360 void Release() { TestMember= false; } \
1361}; \
1362RecursionDetection dbgRecursionDetection( dbgRecursionDetectionFlag ); \
1363ALIB_OWN(dbgRecursionDetection);
1364#else
1365# define ALIB_DBG_PREVENT_RECURSIVE_METHOD_CALLS_MEMBER_DECL
1366# define ALIB_DBG_PREVENT_RECURSIVE_METHOD_CALLS
1367#endif
1368
1369// #################################################################################################
1370// Symbols introduced by lang::DbgCriticalSections
1371// #################################################################################################
1372
1373#if ALIB_DEBUG
1374# if !ALIB_SINGLE_THREADED && ALIB_DEBUG_CRITICAL_SECTIONS
1375# define ALIB_DCS ALIB_OWN(*this)
1376# define ALIB_DCS_SHARED ALIB_OWN_SHARED(*this)
1377# define ALIB_DCS_WITH(CS) ALIB_OWN(CS)
1378# define ALIB_DCS_SHARED_WITH(CS) ALIB_OWN_SHARED(CS)
1379# define ALIB_DCS_ACQUIRE Acquire(ALIB_CALLER);
1380# define ALIB_DCS_RELEASE Release(ALIB_CALLER);
1381# define ALIB_DCS_ACQUIRE_WITH(CS) CS.Acquire(ALIB_CALLER);
1382# define ALIB_DCS_RELEASE_WITH(CS) CS.Release(ALIB_CALLER);
1383# define ALIB_DCS_ACQUIRE_SHARED AcquireShared(ALIB_CALLER);
1384# define ALIB_DCS_RELEASE_SHARED ReleaseShared(ALIB_CALLER);
1385# define ALIB_DCS_ACQUIRE_SHARED_WITH(CS) CS.AcquireShared(ALIB_CALLER);
1386# define ALIB_DCS_RELEASE_SHARED_WITH(CS) CS.ReleaseShared(ALIB_CALLER);
1387# else
1388# define ALIB_DCS { alib::assert::SingleThreaded(); }
1389# define ALIB_DCS_SHARED { alib::assert::SingleThreaded(); }
1390# define ALIB_DCS_WITH(...) { alib::assert::SingleThreaded(); }
1391# define ALIB_DCS_RECURSIVE_WITH(...) { alib::assert::SingleThreaded(); }
1392# define ALIB_DCS_SHARED_WITH(...) { alib::assert::SingleThreaded(); }
1393# define ALIB_DCS_ACQUIRE { alib::assert::SingleThreaded(); }
1394# define ALIB_DCS_RELEASE {}
1395# define ALIB_DCS_ACQUIRE_WITH(CS) { alib::assert::SingleThreaded(); }
1396# define ALIB_DCS_RELEASE_WITH(CS) {}
1397# define ALIB_DCS_ACQUIRE_SHARED { alib::assert::SingleThreaded(); }
1398# define ALIB_DCS_RELEASE_SHARED {}
1399# define ALIB_DCS_ACQUIRE_SHARED_WITH(CS) { alib::assert::SingleThreaded(); }
1400# define ALIB_DCS_RELEASE_SHARED_WITH(CS) {}
1401# endif
1402#else
1403# define ALIB_DCS {}
1404# define ALIB_DCS_SHARED {}
1405# define ALIB_DCS_WITH(...) {}
1406# define ALIB_DCS_RECURSIVE_WITH(...) {}
1407# define ALIB_DCS_SHARED_WITH(...) {}
1408# define ALIB_DCS_ACQUIRE {}
1409# define ALIB_DCS_RELEASE {}
1410# define ALIB_DCS_ACQUIRE_WITH(CS) {}
1411# define ALIB_DCS_RELEASE_WITH(CS) {}
1412# define ALIB_DCS_ACQUIRE_SHARED {}
1413# define ALIB_DCS_RELEASE_SHARED {}
1414# define ALIB_DCS_ACQUIRE_SHARED_WITH(CS) {}
1415# define ALIB_DCS_RELEASE_SHARED_WITH(CS) {}
1416#endif
1417
1418#define bitsof(type) int(sizeof(type) * 8)
1419
1420#endif // INL_ALIB
#define ALIB_SIZEOF_WCHAR_T
Definition alib.inl:857