-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp.d
More file actions
55 lines (40 loc) · 984 Bytes
/
cpp.d
File metadata and controls
55 lines (40 loc) · 984 Bytes
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
/+ SPDX-LICENSE-IDENTIFIER: 0BSD +/
module slack_common.cpp;
struct std_basic_string (Char)
{
union
{
Char[16] inline = 0;
Char* allocated;
}
size_t size;
size_t capacity;
alias asSlice this;
pragma(inline, true)
inout(Char)[] asSlice () inout @property return scope @trusted pure nothrow @nogc
{
return this.base[0 .. this.size];
}
pragma(inline, true)
inout(Char)* base () () inout @property return scope @trusted pure nothrow @nogc
{
return this.capacity >= 16 ? this.allocated : this.inline.ptr;
}
}
alias std_string = std_basic_string!char;
struct std_vector (T)
{
T* base;
T* tail;
alias asSlice this;
pragma(inline, true)
inout(T)[] asSlice () inout @property return scope @trusted pure nothrow @nogc
{
return this.base[0 .. this.tail - this.base];
}
pragma(inline, true)
size_t size () const @property scope @safe pure nothrow @nogc
{
return this.tail - this.base;
}
}