qxLib
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 © 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 != QX_TEXT('\0'))
17  {
18  if (*str == QX_TEXT('\\') || *str == QX_TEXT('/'))
19  pszLastSlash = str;
20 
21  ++str;
22  }
23  return pszLastSlash + 1;
24 }
25 
26 template<class lambda_type>
28 {
29 public:
30  constexpr call_before_main_invoker(lambda_type lambda) : m_Lambda(std::move(lambda))
31  {
32  m_Lambda();
33  }
34 
35 private:
36  lambda_type m_Lambda;
37 };
38 
39 } // namespace qx::details
40 
41 #define _QX_JOIN(symbol1, symbol2) _QX_DO_JOIN(symbol1, symbol2)
42 #define _QX_DO_JOIN(symbol1, symbol2) symbol1##symbol2
43 
44 #if !QX_RELEASE && QX_MSVC
45  #define _QX_DISABLE_OPTIMIZATIONS() __pragma(optimize("", off))
46  #define _QX_ENABLE_OPTIMIZATIONS() __pragma(optimize("", on))
47 #else
48  #define _QX_DISABLE_OPTIMIZATIONS()
49  #define _QX_ENABLE_OPTIMIZATIONS()
50 #endif
51 
52 #if QX_DEBUG && QX_MSVC
53  #define _QX_FORCE_INLINE __forceinline
54 #elif QX_DEBUG && (QX_GNU || QX_CLANG || QX_APPLE_CLANG)
55  #define _QX_FORCE_INLINE inline __attribute__((always_inline))
56 #else
57  #define _QX_FORCE_INLINE inline
58 #endif