Merge branch 'devel' of https://github.com/Araq/Nim into devel

This commit is contained in:
Araq 2014-12-31 16:08:07 +01:00
commit e751a0af57
6 changed files with 65 additions and 8 deletions

26
tests/generics/t1056.nim Normal file
View file

@ -0,0 +1,26 @@
discard """
output: '''TMatrix[3, 3, system.int]
3
3'''
"""
import typetraits
type
TMatrix*[N,M: static[int], T] = object
data*: array[0..N*M-1, T]
TMat2[T] = TMatrix[2,2,T]
proc echoMatrix(a: TMatrix) =
echo a.type.name
echo TMatrix.N
proc echoMat2(a: TMat2) =
echo TMat2.M
var m = TMatrix[3,3,int](data: [1,2,3,4,5,6,7,8,9])
echoMatrix m
echoMat2 m

View file

@ -34,3 +34,20 @@ type
yes s.items is Iter[TNumber]
no s.items is Iter[float]
type
Foo[N: static[int], T] = object
field: array[1..N, T]
Bar[T] = Foo[4, T]
Baz[N: static[int]] = Foo[N, float]
no Foo[2, float] is Foo[3, float]
no Foo[2, float] is Foo[2, int]
yes Foo[4, string] is Foo[4, string]
yes Bar[int] is Foo[4, int]
yes Foo[4, int] is Bar[int]
no Foo[4, int] is Baz[4]
yes Foo[4, float] is Baz[4]