GeoDesk for C++
Fast and storage-efficient spatial database engine for OpenStreetMap features
Loading...
Searching...
No Matches
enum.h
Go to the documentation of this file.
1
// Copyright (c) 2025 Clarisma / GeoDesk contributors
2
// SPDX-License-Identifier: LGPL-3.0-only
3
4
#pragma once
5
#include <type_traits>
6
7
#define CLARISMA_ENUM_FLAGS(EnumType) \
8
constexpr EnumType operator|(EnumType a, EnumType b) noexcept \
9
{ \
10
using U = std::underlying_type_t<EnumType>; \
11
return static_cast<EnumType>(static_cast<U>(a) | static_cast<U>(b)); \
12
} \
13
constexpr EnumType operator&(EnumType a, EnumType b) noexcept \
14
{ \
15
using U = std::underlying_type_t<EnumType>; \
16
return static_cast<EnumType>(static_cast<U>(a) & static_cast<U>(b)); \
17
} \
18
constexpr EnumType& operator|=(EnumType& a, EnumType b) noexcept \
19
{ \
20
a = a | b; \
21
return a; \
22
} \
23
constexpr EnumType& operator&=(EnumType& a, EnumType b) noexcept \
24
{ \
25
a = a & b; \
26
return a; \
27
} \
28
constexpr EnumType operator~(EnumType a) noexcept \
29
{ \
30
return static_cast<EnumType>(~static_cast<uint64_t>(a)); \
31
} \
32
constexpr auto has(EnumType a, EnumType b) noexcept \
33
{ \
34
return static_cast<bool>(a & b); \
35
} \
36
constexpr auto hasAny(EnumType a, EnumType b) noexcept \
37
{ \
38
return static_cast<bool>(a & b); \
39
} \
40
constexpr auto hasAll(EnumType a, EnumType b) noexcept \
41
{ \
42
return (a & b) == b; \
43
} \
44
45
46
/*
47
constexpr bool operator bool(EnumType e) noexcept \
48
{ \
49
return static_cast<uint64_t>(e) != 0; \
50
}
51
*/
include
clarisma
util
enum.h
Generated by
1.12.0