Due to my inability to find an answer or the right words to search for I ask here:
I have a (lengthy) class enum defined by
enum class SomeLongName { Foo = 1, Bar = 7, FooBar = 42 };
The only way I know to define a vector of those is:
#include <vector>
enum class SomeLongName { Foo = 1, Bar = 7, FooBar = 42 };
int main() {
std::vector<SomeLongName> v1 = {
SomeLongName::Foo,
SomeLongName::FooBar
};
return 0;
}
Is there a way (alternative abbreviated syntax) to use a class enum and don't need to rewrite SomeLongName:: for each value independently? e.g. something like (not working)
#include <vector>
enum class SomeLongName { Foo = 1, Bar = 7, FooBar = 42 };
int main() {
std::vector<SomeLongName> v1 = (SomeLongName::) { Foo , Bar };
return 0;
}
In case this matters: I am using MSVC 2019, amd64 (64bit), C++17 on windows 10 64bit
Note: using a typedef like suggested in this stackoverflow discussion thread is not actually what I want or am asking for
using enum SomeLongName;, you can also use a function localusing E = SomeLongName;to shorten the name.