qxLib
include
qx
macros
common.inl
Go to the documentation of this file.
1
/**
2
3
@file common.inl
4
@author Khrapov
5
@date 19.09.2025
6
@copyright (c) Nick Khrapov, 2025. All right reserved.
7
8
**/
9
10
namespace
qx::details
11
{
12
13
constexpr
const
char_type* last_slash(
const
char_type* str)
14
{
15
const
char_type* pszLastSlash = str;
16
while
(str && *str != QXT(
'\0'
))
17
{
18
if
(*str == QXT(
'\\'
) || *str == QXT(
'/'
))
19
pszLastSlash = str;
20
21
++str;
22
}
23
return
pszLastSlash + 1;
24
}
25
26
template
<
class
lambda_t>
27
class
call_before_main_invoker
28
{
29
public
:
30
constexpr
call_before_main_invoker
(lambda_t lambda);
31
32
private
:
33
lambda_t m_Lambda;
34
};
35
36
template
<
class
lambda_t>
37
constexpr
call_before_main_invoker<lambda_t>::call_before_main_invoker
(lambda_t lambda) : m_Lambda(std::move(lambda))
38
{
39
m_Lambda();
40
}
41
42
}
// namespace qx::details
43
44
#define _QX_DO_JOIN(symbol1, symbol2) symbol1##symbol2
45
46
#if !QX_RELEASE && QX_MSVC
47
#define _QX_DISABLE_OPTIMIZATIONS() __pragma(optimize(""
, off))
48
#define _QX_ENABLE_OPTIMIZATIONS() __pragma(optimize(""
, on))
49
#else
50
#define _QX_DISABLE_OPTIMIZATIONS()
51
#define _QX_ENABLE_OPTIMIZATIONS()
52
#endif
53
54
#if !QX_DEBUG && QX_MSVC
55
#define _QX_FORCE_INLINE __forceinline
56
#elif !QX_DEBUG && (QX_GNU || QX_CLANG || QX_APPLE_CLANG)
57
#define _QX_FORCE_INLINE inline __attribute__((always_inline))
58
#else
59
#define _QX_FORCE_INLINE inline
60
#endif
61
62
// clang-format off
63
#define _QX_PRIVATE_APPEND_VA_ARG_COUNT(prefix, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, count, ...) prefix##count
64
65
#if !defined(_MSVC_TRADITIONAL) || !_MSVC_TRADITIONAL
66
#define _QX_APPEND_VA_ARG_COUNT(prefix, ...) _QX_PRIVATE_APPEND_VA_ARG_COUNT(prefix, ##__VA_ARGS__, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
67
#else
68
#define _QX_APPEND_VA_ARG_COUNT_INVOKE(macro, args_in_parens) QX_EXPAND(macro##args_in_parens)
69
#define _QX_APPEND_VA_ARG_COUNT(prefix, ...) _QX_APPEND_VA_ARG_COUNT_INVOKE(_QX_PRIVATE_APPEND_VA_ARG_COUNT, (prefix, ##__VA_ARGS__, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
70
#endif
71
// clang-format on
72
73
#if QX_MSVC
74
#define _QX_EMPTY_BASES __declspec(empty_bases)
75
#else
76
#define _QX_EMPTY_BASES
77
#endif
qx::details::call_before_main_invoker
Definition:
common.inl:28
Generated by
1.9.1