Last active
July 13, 2016 09:37
-
-
Save andreaferretti/6a1caac03a7976c40c36e0cd7710a550 to your computer and use it in GitHub Desktop.
Auto ref types
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
template `~`(x): auto = | |
var h: ref type(x) | |
new(h) | |
h[] = x | |
h | |
type Foo = object | |
a, b, c: ref int | |
d: ref seq[int] | |
var f = Foo(a: ~1, b: ~2, c: ~3, d: ~ @[1, 2, 3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment