Assign varied contents to a Vector without an Array

Hello there,

How would I go about assigning varied content into a vector without multiple push_back() statements? so far, the only method I've found is using an array like this:
1
2
3
int varied[10] = {17,0,3,6,9870,-3,42,-7,99,10101};
vector<int> tedious;
tedious.assign(varied, varied+10);

But I need to create multiple vectors with various different numbers of elements, and having multiple arrays, doesn't appeal to me.

Is there a way that I can assign the contents directly, possibly at initialization?
http://www.cplusplus.com/reference/stl/vector/vector/
Maybe you need the
1
2
template <class InputIterator>
         vector ( InputIterator first, InputIterator last, const Allocator& = Allocator() );

constructor.
I don't think he wants to do it with arrays. I'm guessing he wants something like:

std::vector<int> stuff = {1,2,3,4,5};

Unfortunately, there is no way to do this...at least not until C++0x comes out.
@R0mai

If you notice, the link you posted uses the exact method I used in my example. I found that when I did some extensive searching.

I don't think he wants to do it with arrays. I'm guessing he wants something like:

std::vector<int> stuff = {1,2,3,4,5};

Pretty much.

Unfortunately, there is no way to do this...at least not until C++0x comes out.

Wouldn't it be C++1x by now? Even the latest working draft is from this year.

That said, I just want to be clear. So there is no simple way to add multiple varied elements to a vector, without an array, all at once? I don't really care if it's at initialization.
Topic archived. No new replies allowed.