43 typedef std::list<int, std::allocator<int> > List;
44 typedef std::vector<int, std::allocator<int> >
Vector;
45 typedef std::ostream_iterator<int, char, std::char_traits<char> > os_iter;
48 int a1[] = { 6, -3, -2 };
49 int a2[] = { -2, -3, -2 };
51 List l (
a1,
a1 +
sizeof a1 /
sizeof *
a1);
55 List::value_type prod = std::inner_product (l.begin (), l.end (),
59 List::value_type wacky =
60 std::inner_product (l.begin (), l.end (),
v.begin (), 0,
61 std::plus<List::value_type>(),
62 std::minus<List::value_type>());
64 std::cout <<
"For the sets of numbers: { ";
65 std::copy (
v.begin (),
v.end (), os_iter (std::cout,
" "));
67 std::cout <<
"} and { ";
68 std::copy (l.begin (), l.end (), os_iter (std::cout,
" "));
70 std::cout <<
"}\nThe inner product is: " << prod
71 <<
"\nThe wacky result is: " << wacky
std::vector< UserClass, std::allocator< UserClass > > Vector