For putting a bunch of stuff in a container, there's also Boost.Assign
Code:
#include <boost/assign.hpp>
#include <vector>
int main()
{
using namespace boost::assign;
std::vector<int> v;
v += 14, 15, 26, 1123, 0, 9;
}
With less hassle one might also initialize things from a temporary array:
Code:
#include <vector>
template <class T, std::size_t N>
std::size_t size(const T (&) [N])
{
return N;
};
int main()
{
int array[] = {14, 15, 26, 1123, 0, 9};
std::vector<int> v(array, array + size(array));
}
C++0x is also promising a new kind of constructors, which should allow you to do something like this:
Code:
std::vector<int> v{14, 15, 26, 1123, 0, 9};