In a similar vein to #12714 and #12636
const CacheLineSize = 128
type
Enqueueable = concept x, type T
x is ptr
x.next is Atomic[pointer]
MyChannel*[T: Enqueueable] = object
pad: array[CacheLineSize - sizeof(default(T)[]), byte]
dummy: typeof(default(T)[])
.../bug_sizeof.nim(9, 46) template/generic instantiation of `default` from here
../.choosenim/toolchains/nim-1.0.2/lib/system.nim(1818, 16) Error: invalid type: 'T: Enqueueable' in this context: 'proc (T: type T: Enqueueable): T: Enqueueable{.noSideEffect.}' for proc
Unfortunately there is no workaround since typedesc are now NimNode in macros (nim-lang/RFCs#148 and #11400) and there is no way to convert in NimNode back into a typedesc (#6785)
Otherwise somehing like this would probably work
macro sizeofDeref(T: typedesc): untyped =
let x = default(T)[]
result = newLit sizeof(x)
In a similar vein to #12714 and #12636
Unfortunately there is no workaround since typedesc are now NimNode in macros (nim-lang/RFCs#148 and #11400) and there is no way to convert in NimNode back into a typedesc (#6785)
Otherwise somehing like this would probably work