@Udiknedormin don't object variant use fat pointer anyway?

In any case, I tried version 2 and it makes lots of errors very hard to check.

See [issue #6331](https://github.com/nim-lang/Nim/issues/6331)

In this code the type signature should be 
    
    
    template shape*[B,T](t: Tensor[B,T])
    

instead of 
    
    
    template shape*(t: Tensor)
    

for proper compilation.
    
    
    type
      Backend* = enum
        Cpu,
        Cuda
      
      Tensor*[B: static[Backend]; T] = object
        shape: seq[int]
        strides: seq[int]
        offset: int
        when B == Backend.Cpu:
          data: seq[T]
        else:
          data_ptr: ptr T
    
    template shape*(t: Tensor): seq[int] =
      t.shape
    

Unfortunately the error message points to 
    
    
    when B ==
    

instead of the template line which is a pain when refactoring a huge codebase. 

Reply via email to