I need an "elegant" way of initializing a vector in the declaration phase with the content of another one and a few extra elements.
What I want to solve is:
Let's consider the following (example) declaration with initialization:
const std::vector<std::string> c90_types = {
"char",
"signed char",
"unsigned char",
"short",
"unsigned short",
"int",
"unsigned int",
"long",
"unsigned long",
"float",
"double",
"long double"
};
const std::vector<std::string> c99_types = {
"char",
"signed char",
"unsigned char",
"short",
"unsigned short",
"int",
"unsigned int",
"long",
"unsigned long",
"float",
"double",
"long double",
"long long",
"unsigned long long",
"intmax_t",
"uintmax_t"
};
as you can see c99_types
has a subset which is exactly c90_types
. I want to avoid the situation where I need to change the subset and then change manually the "superset" too, just to avoid the extra step that might introduce bugs :)
As a side note, I don't want to write code like:
second.insert(second.begin(), first.begin(), first.end());
second.push_back(something);
Any good and clean solutions to this?