I know that manual dynamic memory allocation is a bad idea in general, but is it sometimes a better solution than using, say, std::vector
?
To give a crude e
If you know the size in advance (especially at compile time), and don't need the dynamic re-sizing abilities of std::vector
, then using something simpler is fine.
However, that something should preferably be std::array
if you have C++11, or something like boost::scoped_array
otherwise.
I doubt there'll be much efficiency gain unless it significantly reduces code size or something, but it's more expressive which is worthwhile anyway.