In c++11 you can do this wonderful syntax:
vector<int> numbers = {1, 2, 3};
Is there a way to concatenate a further initializer list onto an existing vector?
numbers.??? ({4, 5, 6});
or
std::??? (numbers, {4, 5, 6});
You can use std::vector::insert
for that:
#include <vector> vector<int> numbers = {1, 2, 3}; numbers.insert( numbers.end(), {4, 5, 6} );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With