support for inferring static[T] concept params
This commit is contained in:
parent
8cd5f1f8f5
commit
76c663f692
8 changed files with 144 additions and 28 deletions
15
tests/concepts/tvectorspace.nim
Normal file
15
tests/concepts/tvectorspace.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
type VectorSpace[K] = concept x, y
|
||||
x + y is type(x)
|
||||
zero(type(x)) is type(x)
|
||||
-x is type(x)
|
||||
x - y is type(x)
|
||||
var k: K
|
||||
k * x is type(x)
|
||||
|
||||
proc zero(T: typedesc): T = 0
|
||||
|
||||
static:
|
||||
assert float is VectorSpace[float]
|
||||
# assert float is VectorSpace[int]
|
||||
# assert int is VectorSpace
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue