Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- Vec[N: static[int], T] = object
- data: array[N, T]
- proc newVec[N: static int, T](arr: array[N, T]): Vec[N,T] = discard
- proc `+`[A: Vec](a: A; t: A.T): string = "A"
- proc `+`[A: Vec](t: A.T; a: A): string = "B"
- let v = newVec([0.0])
- echo v + 1.0 # no problem
- echo 1.0 + v # error: Cannot instantiate Vec[N,T] inside of type definition `+`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement