I wonder if there is the \"nicer\" way of initialising a static vector than below?
class Foo
{
static std::vector MyVector;
Foo()
{
Typically, I have a class for constructing containers that I use (like this one from boost), such that you can do:
const list primes = list_of(2)(3)(5)(7)(11);
That way, you can make the static const as well, to avoid accidental modifications.
For a static, you could define this in the .cc file:
// Foo.h
class Foo {
static const vector something;
}
// Foo.cc
const vector Foo::something = list_of(3)(5);
In C++Ox, we'll have a language mechanism to do this, using initializer lists, so you could just do:
const vector primes({2, 3, 5, 7, 11});
See here.