
1 Mar
2007
1 Mar
'07
6:27 a.m.
I have functions like say a quartic equation solver that can return a variable number of solutions. It would be clean IMO to return or pass by reference a std::vector or like container that store the solutions. However heap allocation is fairly expensive here so the usual solution is to have a local array with max solutions elements and pass that by reference into the solver and return the number of solutions. This is ugly to use and read. Is there a library for stack-based std-like containers? Alternatively is it possible to make an compatible stack-based allocator for std::vector using alloca? Thanks, Michael Marcin