Initialize a vector array of strings

c++, stl

Solution

Sort of:

class some_class {
    static std::vector<std::string> v; // declaration
};

const char *vinit[] = {"one", "two", "three"};

std::vector<std::string> some_class::v(vinit, end(vinit)); // definition

`end` is just so I don't have to write `vinit+3` and keep it up to date if the length changes later. Define it as:

template<typename T, size_t N>
T * end(T (&ra)[N]) {
    return ra + N;
}

Problem

Would it be possible to initialize a vector array of strings? for example: ``` static std::vector<std::string> v; //declared as a class member ``` I used `static` just to initialize and fill it with strings. Or should i just fill it in the constructor if it can't be initialized like we do with regular arrays.

Original source