Skip to content

Instantly share code, notes, and snippets.

@schveiguy
schveiguy / eponymous.d
Last active May 27, 2017 01:04
Voldemort types article
module eponymous;
template inputChain(R1, R2)
if(isInputRange!R1 && isInputRange!R2 &&
is(ElementType!R1 == ElementType!R2))
{
auto inputChain(R1 r1, R2 r2)
{
...
}
@schveiguy
schveiguy / ex1_a.d
Last active August 29, 2016 14:06
2.071.0 import article
module ex1_a;
void foo() {}
@schveiguy
schveiguy / local_ref.d
Last active February 22, 2016 03:37
D inout article
struct LocalRef(T)
{
private T* _ref;
this(ref T t) { _ref = &t; }
ref T get() pure { return *_ref; }
}
void main()
{
int x;
@schveiguy
schveiguy / struct_with_properties.swift
Last active February 22, 2016 02:54
Code for swift/d comparison
struct S
{
var x : Int // uses hidden storage
var xTimes10 : Int {
get {
return x * 10
}
set {
x = newValue / 10
}