Support the recommended init scheme for tables

This commit is contained in:
Zahary Karadjov 2019-03-12 04:32:08 +02:00
parent 3b28f390fc
commit ee5865574b
2 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,16 @@
template init*(lvalue: var auto, args: varargs[untyped]) = template init*(lvalue: var auto) =
mixin init mixin init
lvalue = init(type(lvalue), args) lvalue = init(type(lvalue))
template init*(lvalue: var auto, a1: auto)=
mixin init
lvalue = init(type(lvalue), a1)
template init*(lvalue: var auto, a1, a2: auto) =
mixin init
lvalue = init(type(lvalue), a1, a2)
template init*(lvalue: var auto, a1, a2, a3: auto) =
mixin init
lvalue = init(type(lvalue), a1, a2, a3)

View File

@ -0,0 +1,5 @@
import tables, objects
template init*[A, B](T: type Table[A, B]): auto = initTable[A, B]()
export tables, objects