In C++11
you can use vector
's initializer-list constructor:
vector<A> list {a1, a2, a3, a4, a5};
If C++11
isn't available you can use the iterator
based constructor if you create a temporary array, but it's not as clean as the C++11
solution:
A tmp_list[] = {a1, a2, a3, a4, a5};
vector<A> list(tmp_list, tmp_list + 5};