how-to initialize 'const std::vector<T>' like a c array
- by vscharf
Is there an elegant way to create and initialize a const std::vector<const T> like const T a[] = { ... } to a fixed (and small) number of values?
I need to call a function frequently which expects a vector<T>, but these values will never change in my case.
In principle I thought of something like
namespace {
const std::vector<const T> v(??);
}
since v won't be used outside of this compilation unit.