-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathutils.hpp
40 lines (29 loc) · 1.17 KB
/
utils.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-License-Identifier: MIT
// Copyright © 2024 Dylan Baker
// Copyright © 2024 Bret Brown
#pragma once
#include "cps/config.hpp"
#include <fmt/core.h>
#include <string>
#include <vector>
namespace cps::utils {
inline void assert_fn(bool expr, std::string_view msg) {
if (!expr) {
fmt::print(stderr, "{}\n", msg);
fflush(stderr);
abort();
}
}
} // namespace cps::utils
#if CPS_USE_BUILTIN_UNREACHABLE
#define CPS_UNREACHABLE(msg) \
do { \
cps::utils::assert_fn(false, msg); \
__builtin_unreachable(); \
} while (0)
#else
#define CPS_UNREACHABLE(msg) cps::utils::assert_fn(false, msg);
#endif
namespace cps::utils {
std::vector<std::string> split(std::string_view input, std::string_view delim = ":");
} // namespace cps::utils