"Joe Laughlin" <Joseph.V.Laugh lin@boeing.com> wrote...[color=blue]
> Is there any way to initialize a vector with a bunch of values at once,
> instead of doing a bunch of push_back()'s?[/color]
Yes, if you don't mind having those values in an array:
Joe Laughlin wrote:[color=blue]
> Is there any way to initialize a vector with a bunch of values at once,
> instead of doing a bunch of push_back()'s?[/color]
template<typena me T, unsigned N>
std::vector<T> Initialize( const T (&i_v)[N] )
{
return std::vector<T>( &(i_v[0]), &(i_v[N]) );
}
This page provides a list of the pages of BDSoft.com, and a little info about each one. If you are lost on our site, try using the sitemap to find what you are looking for.
"Joe Laughlin" <Joseph.V.Laugh lin@boeing.com> wrote in message
[color=blue]
> Is there any way to initialize a vector with a bunch of values at once,
> instead of doing a bunch of push_back()'s?[/color]
If you want to initialize all elements to the same value:
vector<int> v(10, -1);
Other posts talk about initializing from an array, also very useful.
Comment