39operator<< (std::ostream &
out,
const std::vector<
T, std::allocator<T> > &
v)
41 typedef std::ostream_iterator<T, char, std::char_traits<char> >
Iter;
43 std::copy (
v.begin (),
v.end (),
Iter (
out,
" "));
51 const int a[] = { 9, 8, 7, 6, 5, 4, 3, 2, 1 };
53 typedef std::vector<int, std::allocator<int> > IntVector;
54 typedef std::vector<double, std::allocator<double> > DblVector;
59 const IntVector vi (
a,
a +
sizeof a /
sizeof *
a);
60 DblVector vd (vi.begin (), vi.end ());
64 std::cout.precision (2);
66 std::cout << vi <<
'\n' << vd <<
'\n';
70 const IntVector::size_type mid = vi.size () / 2;
75 vd.assign (vi.begin (), vi.begin () + mid);
80 vd.insert (vd.end (),
a + mid,
a +
sizeof a /
sizeof *
a);
83 std::cout << vd <<
'\n';
std::ostream_iterator< int, char, std::char_traits< char > > Iter
std::ostream & operator<<(std::ostream &out, const std::vector< T, std::allocator< T > > &v)