HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
hikogui
required.hpp
Go to the documentation of this file.
1
// Copyright Take Vos 2019-2021.
2
// Distributed under the Boost Software License, Version 1.0.
3
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
10
#pragma once
11
12
#include <cstddef>
13
#include <string>
14
#include <chrono>
15
16
#ifndef hilet
23
#define hilet auto const
24
#endif
25
26
#ifndef hi_forward
29
#define hi_forward(x) std::forward<decltype(x)>(x)
30
#endif
31
32
// One clang-format off is not enough to stop clang-format to format.
33
// clang-format off
34
// clang-format off
35
#define hi_num_va_args_impl( \
36
_1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
37
_11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
38
_21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
39
_31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
40
_41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
41
_51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
42
_61,_62,_63,N,...) N
43
#define hi_num_va_args_(...) hi_num_va_args_impl(__VA_ARGS__)
44
50
#define hi_num_va_args(...) hi_num_va_args_(__VA_ARGS__ __VA_OPT__(,) \
51
63,62,61,60, \
52
59,58,57,56,55,54,53,52,51,50, \
53
49,48,47,46,45,44,43,42,41,40, \
54
39,38,37,36,35,34,33,32,31,30, \
55
29,28,27,26,25,24,23,22,21,20, \
56
19,18,17,16,15,14,13,12,11,10, \
57
9,8,7,6,5,4,3,2,1,0)
58
// clang-format on
59
60
#define hi_parans ()
61
62
#define hi_expand1(...) __VA_ARGS__
63
#define hi_expand2(...) hi_expand1(hi_expand1(hi_expand1(hi_expand1(__VA_ARGS__))))
64
#define hi_expand3(...) hi_expand2(hi_expand2(hi_expand2(hi_expand2(__VA_ARGS__))))
65
#define hi_expand4(...) hi_expand3(hi_expand3(hi_expand3(hi_expand3(__VA_ARGS__))))
66
71
#define hi_expand(...) hi_expand4(hi_expand4(hi_expand4(hi_expand4(__VA_ARGS__))))
72
73
#define hi_for_each_again() hi_for_each_helper
74
#define hi_for_each_helper(macro, first_arg, ...) macro(first_arg) __VA_OPT__(hi_for_each_again hi_parans(macro, __VA_ARGS__))
75
81
#define hi_for_each(macro, ...) __VA_OPT__(hi_expand(hi_for_each_helper(macro, __VA_ARGS__)))
82
83
#define hi_stringify_(x) #x
84
#define hi_stringify(x) hi_stringify_(x)
85
86
#define hi_cat_(a, b) a##b
87
#define hi_cat(a, b) hi_cat_(a, b)
88
89
#define hi_return_on_self_assignment(other) \
90
if (&(other) == this) [[unlikely]] \
91
return *this;
92
93
#if defined(__clang__)
94
#define hi_unreachable() __builtin_unreachable()
95
#define hi_assume(condition) __builtin_assume(to_bool(condition))
96
#define hi_force_inline inline __attribute__((always_inline))
97
#define hi_no_inline __attribute__((noinline))
98
#define hi_restrict __restrict__
99
#define hi_warning_push() _Pragma("warning(push)")
100
#define hi_warning_pop() _Pragma("warning(push)")
101
#define hi_warning_ignore_msvc(code)
102
#define hi_warning_ignore_clang(a) _Pragma(hi_stringify(clang diagnostic ignored a))
103
#define hi_export
104
#define hi_typename typename
105
#define hi_constexpr
106
107
#elif defined(_MSC_BUILD)
108
#define hi_unreachable() __assume(0)
109
#define hi_assume(condition) __assume(condition)
110
#define hi_force_inline __forceinline
111
#define hi_no_inline __declspec(noinline)
112
#define hi_restrict __restrict
113
#define hi_warning_push() _Pragma("warning( push )")
114
#define hi_warning_pop() _Pragma("warning( pop )")
115
#define hi_msvc_pragma(a) _Pragma(a)
116
#define hi_warning_ignore_msvc(code) _Pragma(hi_stringify(warning(disable : code)))
117
#define hi_warning_ignore_clang(a)
118
#define hi_export __declspec(dllexport)
119
#define hi_typename
120
#define hi_constexpr constexpr
121
122
#elif defined(__GNUC__)
123
#define hi_unreachable() __builtin_unreachable()
124
#define hi_assume(condition) \
125
do { \
126
if (!(condition)) \
127
hi_unreachable(); \
128
} while (false)
129
#define hi_force_inline inline __attribute__((always_inline))
130
#define hi_no_inline __attribute__((noinline))
131
#define hi_restrict __restrict__
132
#define hi_warning_push() _Pragma("warning(push)")
133
#define hi_warning_pop() _Pragma("warning(pop)")
134
#define hi_msvc_pragma(a)
135
#define hi_warning_ignore_clang(a)
136
#define msvc_pragma(a)
137
#define hi_typename
138
139
#else
140
#define hi_unreachable() std::terminate()
141
#define hi_assume(condition) static_assert(sizeof(condition) == 1)
142
#define hi_force_inline inline
143
#define hi_no_inline
144
#define hi_restrict
145
#define hi_warning_push()
146
#define hi_warning_pop()
147
#define hi_msvc_pragma(a)
148
#define hi_warning_ignore_clang(a)
149
#define msvc_pragma(a)
150
#define hi_typename
151
#endif
152
153
hi_warning_push();
154
// C26472: Don't use static_cast for arithmetic conversions, Use brace initialization, gsl::narrow_cast or gsl::narrow (type.1).
155
// We do not have access to narrow_cast in this file.
156
hi_warning_ignore_msvc(26472);
157
158
namespace
hi::inline v1 {
159
162
using
ssize_t
=
std::ptrdiff_t
;
163
164
#define ssizeof(x) (static_cast<ssize_t>(sizeof(x)))
165
166
constexpr
std::size_t
operator
""
_uz(
unsigned
long
long
lhs)
noexcept
167
{
168
return
static_cast<
std::size_t
>
(lhs);
169
}
170
171
constexpr
std::size_t
operator
""
_zu(
unsigned
long
long
lhs)
noexcept
172
{
173
return
static_cast<
std::size_t
>
(lhs);
174
}
175
176
constexpr
std::ptrdiff_t
operator
""
_z(
unsigned
long
long
lhs)
noexcept
177
{
178
return
static_cast<
std::ptrdiff_t
>
(lhs);
179
}
180
181
}
// namespace hi::inline v1
182
183
hi_warning_pop();
std::ptrdiff_t
std::size_t
Generated on Mon Apr 22 2024 12:52:40 for HikoGUI by
1.10.0