Just an update on the question of pushing seqs in a double queue without copy.
I tried this:
import deques
proc `<-`[T](lhs: var T, rhs: var T) {.noSideEffect, magic: "ShallowCopy".}
type
container[T] = object
val: seq[T]
proc `=`[T](d: var container[T], s: container[T]) =
echo "copy"
echo s.val
d.val <- s.val
var c = container[int](val: @[1, 2, 3])
echo repr(c.val)
echo cast[int](c.val[1].addr)
var deque = initDeque[container[int]]()
deque.addFirst(c)
var c2 = deque.popFirst()
echo repr(c2.val)
echo cast[int](c2.val[1].addr)
But it does not work. I looked at the implementation of deque but I dont see
from where comes the problem.
However I found an easier solution:
import deques
type
container[T] = ref object
val: seq[T]
var c = container[int](val: @[1, 2, 3])
echo repr(c.val)
echo cast[int](c.val[1].addr)
var deque = initDeque[container[int]]()
deque.addFirst(c)
var c2 = deque.popFirst()
echo repr(c2.val)
echo cast[int](c2.val[1].addr)
Which works as I want.