Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
Foundation/Common/Common.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Common_Common_h_
5#define _Stroika_Foundation_Common_Common_h_ 1
6
7#include <cstddef>
8#include <cstdint>
9
10namespace Stroika {
11 using namespace std;
12
13 // deal with windows ambiguity - C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\rpcndr.h(202): note: could be 'unsigned char byte'
14 using std::byte;
15}
16
18
19#if qCompilerAndStdLib_AssumeWarningSpamming_Buggy
20 // INTENTIONALLY UNBALANCED WITH _END - cuz this is used all over the place!!!
21 DISABLE_COMPILER_CLANG_WARNING_START ("clang diagnostic ignored \"-Wassume\"");
22#endif
23
24 /**
25 * The assume attribute was introduced in c++23, and Stroika OPTIONALLY supports this, but doesn't require it as of Stroika v3.
26 * So use _ASSUME_ATTRIBUTE_ () to conditionally use [[assume(X)]]
27 */
28#if __has_cpp_attribute(assume)
29#define _ASSUME_ATTRIBUTE_(X) [[assume (X)]];
30#elif _MSC_VER
31 // Docs not clear.
32 // https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1774r4.pdf suggests this hack. BUT...
33 // https://github.com/MicrosoftDocs/cpp-docs/blob/main/docs/build/optimization-best-practices.md seems to hint __assume doesn't evaluate X, except to pay attention to simple a>constant compares so this should be OK
34#define _ASSUME_ATTRIBUTE_(X) __assume (X);
35#else
36#define _ASSUME_ATTRIBUTE_(X)
37#endif
38
39 /**
40 * \def nonvirtual
41 * Is for documentation purposes, to make clear a method is intended to be not 'virtual'
42 *
43 * \par Example Usage
44 * \code
45 * // Conventional std c++
46 * struct base {
47 * int f1 ();
48 * virtual int f2();
49 * };
50 * struct derived : base {
51 * // f2 is a virtual override here, but it sure isn't clear from the declaration
52 * int f2 ();
53 * };
54 *
55 * // In Stroika, this will always be written as:
56 * struct base {
57 * nonvirtual int f1 ();
58 * virtual int f2();
59 * };
60 * struct derived : base {
61 * // f2 is a virtual override here, but it sure isn't clear from the declaration
62 * virtual int f2 () override;
63 * };
64 * \endcode
65 *
66 * So its always clear at the point of declaration if a function is virtual or not, and if virtual, if its
67 * a new virtual or override.
68 *
69 * \note This is \em not really enforced by the compiler (the 'conventional std c++ code' produces no diagnostic).
70 */
71#define nonvirtual
72
73}
74
75/*
76 ********************************************************************************
77 ***************************** Implementation Details ***************************
78 ********************************************************************************
79 */
80
81#endif /*_Stroika_Foundation_Common_Common_h_*/
STL namespace.