-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
sys.pat
59 lines (49 loc) · 1.64 KB
/
sys.pat
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
import std.io;
/*!
Basic helper functions
*/
namespace auto std {
/**
Asserts that a given value is true. If it's not, abort evaluation and print the given message to the console
@param condition The condition that is required to be true
@param message The message to print in case the assertion doesn't hold
*/
fn assert(bool condition, str message) {
if (!condition) {
std::error(std::format("assertion failed '{0}'", message));
}
};
/**
Asserts that a given value is true. If it's not, print the given message to the console as a warning
@param condition The condition that is required to be true
@param message The message to print in case the assertion doesn't hold
*/
fn assert_warn(bool condition, str message) {
if (!condition) {
std::warning(std::format("assertion failed '{0}'", message));
}
};
/**
Queries the value of a set environment variable given it's name
@param name The name of the env variable
@return The value of that variable
*/
fn env(str name) {
return builtin::std::env(name);
};
/**
Returns the number of parameters in a parameter pack.
@param pack The pack to check
@return Number of parameters in `pack`
*/
fn sizeof_pack(auto ... pack) {
return builtin::std::sizeof_pack(pack);
};
/**
Throws an error notifying the developer that the current code path is not implemented currently.
*/
fn unimplemented() {
std::error("Unimplemented code path reached!");
};
}