SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
Macros.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <type_traits>
4
5
// Helpers
6
#define SOURCEPP_CONCAT_DETAIL(a, b) a##b
7
#define SOURCEPP_CONCAT(a, b) SOURCEPP_CONCAT_DETAIL(a, b)
8
10
#ifdef DEBUG
11
#if defined(_MSC_VER)
12
#define SOURCEPP_DEBUG_BREAK __debugbreak()
13
#elif defined(__linux__)
14
#include <csignal>
15
#define SOURCEPP_DEBUG_BREAK std::raise(SIGINT)
16
#endif
17
#endif
18
#ifndef SOURCEPP_DEBUG_BREAK
19
#define SOURCEPP_DEBUG_BREAK
20
#endif
21
23
#define SOURCEPP_UNIQUE_NAME(base) SOURCEPP_CONCAT(base, __LINE__)
24
26
#define SOURCEPP_BITFLAGS_ENUM(Enum) \
27
template<typename T> \
28
requires std::is_same_v<T, Enum> || std::is_integral_v<T> \
29
constexpr inline Enum operator|(Enum lhs, T rhs) { \
30
return static_cast<Enum>( \
31
static_cast<std::underlying_type_t<Enum>>(lhs) | \
32
static_cast<std::underlying_type_t<Enum>>(rhs)); \
33
} \
34
template<typename T> \
35
requires std::is_same_v<T, Enum> || std::is_integral_v<T> \
36
constexpr inline Enum operator&(Enum lhs, T rhs) { \
37
return static_cast<Enum>( \
38
static_cast<std::underlying_type_t<Enum>>(lhs) & \
39
static_cast<std::underlying_type_t<Enum>>(rhs)); \
40
} \
41
template<typename T> \
42
requires std::is_same_v<T, Enum> || std::is_integral_v<T> \
43
constexpr inline Enum operator^(Enum lhs, T rhs) { \
44
return static_cast<Enum>( \
45
static_cast<std::underlying_type_t<Enum>>(lhs) ^ \
46
static_cast<std::underlying_type_t<Enum>>(rhs)); \
47
} \
48
constexpr inline Enum operator~(Enum e) { \
49
return static_cast<Enum>( \
50
~static_cast<std::underlying_type_t<Enum>>(e)); \
51
} \
52
template<typename T> \
53
requires std::is_same_v<T, Enum> || std::is_integral_v<T> \
54
constexpr inline Enum& operator|=(Enum& lhs, T rhs) { \
55
return lhs = static_cast<Enum>( \
56
static_cast<std::underlying_type_t<Enum>>(lhs) | \
57
static_cast<std::underlying_type_t<Enum>>(rhs)); \
58
} \
59
template<typename T> \
60
requires std::is_same_v<T, Enum> || std::is_integral_v<T> \
61
constexpr inline Enum& operator&=(Enum& lhs, T rhs) { \
62
return lhs = static_cast<Enum>( \
63
static_cast<std::underlying_type_t<Enum>>(lhs) & \
64
static_cast<std::underlying_type_t<Enum>>(rhs)); \
65
} \
66
template<typename T> \
67
requires std::is_same_v<T, Enum> || std::is_integral_v<T> \
68
constexpr inline Enum& operator^=(Enum& lhs, T rhs) { \
69
return lhs = static_cast<Enum>( \
70
static_cast<std::underlying_type_t<Enum>>(lhs) ^ \
71
static_cast<std::underlying_type_t<Enum>>(rhs)); \
72
}
include
sourcepp
Macros.h
Generated by
1.9.6