Let's say I'd like to have a std::vector of unsigned chars. It's initialized with an initializer-list (this is C++11) and will never change. I'd like to avoid any heap allocation, even at startup time, and have the whole vector live in the data segment like const strings. Is that possible? I.e: static const vector<char> v{0x1, 0x2, 0x3, 0x0, 0x5};
(This is a somewhat academic question; I know it's not that hard to just use C arrays for this.)
Aucun commentaire:
Enregistrer un commentaire