This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@-moz-document regexp("https?://(www\.|forum\.)?dlang.org/(|library|library-prerelease|phobos|phobos-prerelease|spec)(.*)") { | |
body { | |
color: #BFBFBF !important; | |
background-color: #222 !important; | |
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAgMAAAANjH3HAAAACVBMVEUaGhohISElJSUh9lebAAAB20lEQVRIx4XWuZXDMAwE0C0SAQtggIIYoAAEU+aKOHhYojTrYP2+QfOW/5QIJOih/q8HwF/pb3EX+UPIveYcQGgEHiu9hI+ihEc5Jz5KBIlRRRaJ1JtoSAl5Hw96hLB1/up1tnIXOck5jZQy+3iU2hAOKSH1JvwxHsp+5TLF5MOl1/MQXsVs1miXc+KDbYydyMeUgpPQreZ7fWidbNhkXNJSeAhc6qHmHD8AYovunYyEACWEbyIhNeB9fRrH3hFi0bGPLuEW7xCNaohw1vAlS805nfsrTspclB/hVdoqusg53eH7FWot+wjYpOViX8KbFFKTwlnzvj65P9H/vD0/hibYBGhPwlPO8TmxRsaxsNnrUmUXpNhirlJMPr6Hqq9k5Xn/8iYQHYIuQsWFC6Z87IOxLxHphSY4SpuiU87xJnJr5axfeRd+lnMExXpEWPpuZ1v7qZdNBOjiHzDREHX5fs5Zz9p6X0vVKbKKchlSl5rv+3p//FJ/PYvoKryI8vs+2G9lzRmnEKkh+BU8yDk515jDj/HAswu7CCz6U/Mxb/PnC9N41ndpU4hUU7JGk/C9PmP/M2xZYdvBW2PObyf1IUiIzoHmHW9yTncliYs9A9tVNppdShfgQaTLMf+j3X723tLeHgAAAABJRU5ErkJggg==) !important; | |
background-cl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.traits : FunctionAttribute; | |
private string faToString(FunctionAttribute fa) | |
{ | |
import std.algorithm, std.traits; | |
string result; | |
foreach (member; __traits(derivedMembers, FunctionAttribute)) | |
{ | |
if (fa & __traits(getMember, FunctionAttribute, member)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IDisposable | |
{ | |
void dispose(); | |
} | |
auto using(T : IDisposable, CtorArgs...)(auto ref CtorArgs ctorArgs) | |
if(is(T == class) && __traits(compiles, new T(ctorArgs))) | |
{ | |
static struct Result | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Takes instances of `Foo` | |
struct Foo(T){ T t; } | |
string takesFoo(T)(T t) if(is(T == Foo!U, U)) | |
{ | |
static if(is(T == Foo!U, U)) | |
return U.stringof; | |
else | |
static assert(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mixin template ExceptionConstructor() | |
{ | |
@safe pure nothrow | |
this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) | |
{ | |
super(msg, file, line, next); | |
} | |
} | |
mixin template ExceptionConstructor(string defaultMessage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env rdmd | |
/** | |
* Output a makefile-compatible list of source files | |
* given a list of directories containing the files. | |
* Example: | |
* ./list_sources.d src util >> Makefile | |
*/ | |
import std.algorithm, std.path; | |
// returns range of file paths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Could use `alias front` instead to bind to single characters as well | |
mixin template DeclareVars(T, string front, names...) | |
{ | |
mixin("T " ~ front ~ ";"); | |
static if(names.length > 0) | |
mixin DeclareVars!(T, names); | |
} | |
struct S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.typecons : Tuple; | |
import std.typetuple : TypeTuple; | |
template NameTypePairs(alias front, vars...) | |
{ | |
private enum name = __traits(identifier, front); | |
private alias pair = TypeTuple!(typeof(front), name); | |
static if(vars.length == 0) | |
alias NameTypePairs = pair; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import core.exception : onOutOfMemoryError; | |
import core.stdc.stdlib : malloc, free; | |
import std.conv : emplace; | |
T alloc(T, Args...)(auto ref Args args) if(is(T == class)) | |
{ | |
enum size = __traits(classInstanceSize, T); | |
if(auto p = malloc(size)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto values(Elems...)(auto ref Elems elems) if(is(CommonType!Elems)) | |
{ | |
alias CommonType!Elems ElemType; | |
static struct StaticArray | |
{ | |
ElemType[Elems.length] data = void; | |
size_t i = 0; | |
bool empty() const |
NewerOlder