Skip to content

Instantly share code, notes, and snippets.

View run-dlang's full-sized avatar

Eleanor Cross run-dlang

View GitHub Profile
@run-dlang
run-dlang / main.d
Created April 2, 2018 21:29
Code shared from run.dlang.io
import std.stdio;
void main()
{
writeln("Hello D2222");
}
@run-dlang
run-dlang / main.d
Created April 2, 2018 21:36
Code shared from run.dlang.io.
import std.stdio;
void main()
{
writeln("Hello D2222");
}
@run-dlang
run-dlang / main.d
Created April 2, 2018 21:37
Code shared from run.dlang.io.Run with '-dip1000'
import std.stdio;
void main()
{
writeln("Hello D2222");
}
@run-dlang
run-dlang / main.d
Created April 3, 2018 06:37
Code shared from run.dlang.io.
struct Test(T...)
{
T field;
this (T t) { field = t; }
bool opEquals(R...)(const auto ref R rhs) inout
{
static foreach (i, _; T)
if (field[i] != rhs[i])
@run-dlang
run-dlang / main.d
Created April 3, 2018 14:44
Code shared from run.dlang.io.
void main()
{
import std.experimental.allocator;
import std.experimental.allocator.mallocator: Mallocator;
import std.experimental.allocator.gc_allocator : GCAllocator;
auto newAlloc = sharedAllocatorObject(Mallocator.instance);
processAllocator() = newAlloc;
assert(processAllocator is newAlloc);
processAllocator = sharedAllocatorObject(GCAllocator.instance);
}
@run-dlang
run-dlang / main.d
Created April 3, 2018 14:50
Code shared from run.dlang.io.
void main()
{
import std.stdio: write, writeln, writef, writefln;
int i;
enum Foo { E }
Foo f;
i = f; // OK
f = i; // error
f = cast(Foo)i; // OK
@run-dlang
run-dlang / main.d
Created April 5, 2018 07:37
Code shared from run.dlang.io.
import std.stdio;
mixin template Enforcement(T) {
private bool _ensured;
private Throwable _throwable;
~this() {
if (this.hasThrowable) {
throw _throwable;
}
@run-dlang
run-dlang / main.d
Created April 5, 2018 13:38
Code shared from run.dlang.io.
import std.concurrency : receiveOnly, send,
spawn, Tid, thisTid;
import core.atomic : atomicOp, atomicLoad;
import core.sync.mutex;
shared Mutex mtx;
/*
Queue that can be used safely among
@run-dlang
run-dlang / main.d
Created April 5, 2018 13:38
Code shared from run.dlang.io.
import std.concurrency : receiveOnly, send,
spawn, Tid, thisTid;
import core.atomic : atomicOp, atomicLoad;
import core.sync.mutex;
shared Mutex mtx;
/*
Queue that can be used safely among
@run-dlang
run-dlang / main.d
Created April 5, 2018 13:38
Code shared from run.dlang.io.
import std.concurrency : receiveOnly, send,
spawn, Tid, thisTid;
import core.atomic : atomicOp, atomicLoad;
import core.sync.mutex;
shared Mutex mtx;
/*
Queue that can be used safely among