further improvements for static generic params; activate the hardest test cases
This commit is contained in:
parent
45a345e93d
commit
9fb0755572
4 changed files with 45 additions and 23 deletions
|
|
@ -1,6 +1,6 @@
|
|||
discard """
|
||||
file: "tstaticparams.nim"
|
||||
output: "abracadabra\ntest\n3"
|
||||
output: "abracadabra\ntest\n3\n15"
|
||||
"""
|
||||
|
||||
type
|
||||
|
|
@ -11,8 +11,8 @@ type
|
|||
data: array[I, T]
|
||||
|
||||
TA1[T; I: static[int]] = array[I, T]
|
||||
# TA2[T; I: static[int]] = array[0..I, T]
|
||||
# TA3[T; I: static[int]] = array[I-1, T]
|
||||
TA2[T; I: static[int]] = array[0..I, T]
|
||||
TA3[T; I: static[int]] = array[I-1, T]
|
||||
|
||||
proc takeFoo(x: TFoo) =
|
||||
echo "abracadabra"
|
||||
|
|
@ -26,6 +26,18 @@ echo high(y.data)
|
|||
|
||||
var
|
||||
t1: TA1[float, 1]
|
||||
# t2: TA2[string, 4]
|
||||
# t3: TA3[int, 10]
|
||||
t2: TA2[string, 4]
|
||||
t3: TA3[int, 10]
|
||||
|
||||
# example from the manual:
|
||||
type
|
||||
Matrix[M,N: static[int]; T] = array[0..(M*N - 1), T]
|
||||
# Note how `Number` is just a type constraint here, while
|
||||
# `static[int]` requires us to supply a compile-time int value
|
||||
|
||||
AffineTransform2D[T] = Matrix[3, 3, T]
|
||||
AffineTransform3D[T] = Matrix[4, 4, T]
|
||||
|
||||
var m: AffineTransform3D[float]
|
||||
echo high(m)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue