how-to initialize 'const std::vector<T>' like a c array
Posted
by vscharf
on Stack Overflow
See other posts from Stack Overflow
or by vscharf
Published on 2008-10-23T20:54:59Z
Indexed on
2010/06/02
17:34 UTC
Read the original article
Hit count: 127
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.
© Stack Overflow or respective owner