How can I define element size dynamically ?

Author: whatagoodnameCreated Feb 11, 2026Updated Feb 11, 2026

In my project, I need multiple producer threads to generate objects of a certain data type, and the size of this object is determined by an externally passed JSON during program runtime. However, it seems that our lock-free queue can only allocate memory based on the compile-time-specified T and sizeof(T)? I have tried using <char> as T and then enqueuing n chars in bulk mode, but the speed is much slower compared to when T = std::array<char, n>. Is there any way for me to dynamically modify the element size recognized by the lock-free queue? Does this require modifying the source code to achieve?

Source: cameron314/concurrentqueue