36typedef std::multimap<int, std::string, std::less<int>,
37 std::allocator<std::pair<const int, std::string> > >
45 for (months_type::const_iterator it =
m.begin (); it !=
m.end (); ++it)
46 std::cout << (*it).second <<
" has " << (*it).first <<
" days\n";
57 typedef months_type::value_type value_type;
61 months.insert (value_type (31, std::string (
"January")));
62 months.insert (value_type (28, std::string (
"Febuary")));
63 months.insert (value_type (31, std::string (
"March")));
64 months.insert (value_type (30, std::string (
"April")));
65 months.insert (value_type (31, std::string (
"May")));
66 months.insert (value_type (30, std::string (
"June")));
67 months.insert (value_type (31, std::string (
"July")));
68 months.insert (value_type (31, std::string (
"August")));
69 months.insert (value_type (30, std::string (
"September")));
70 months.insert (value_type (31, std::string (
"October")));
71 months.insert (value_type (30, std::string (
"November")));
72 months.insert (value_type (31, std::string (
"December")));
75 std::cout <<
"All months of the year\n" << months << std::endl;
78 std::pair<months_type::iterator, months_type::iterator>
p =
79 months.equal_range (30);
82 std::cout <<
"\nMonths with 30 days\n";
84 for ( ;
p.first !=
p.second; ++
p.first)
85 std::cout << (*
p.first).second <<
'\n';
std::map< std::string, int, std::less< std::string >, std::allocator< std::pair< const std::string, int > > > months_type
std::ostream & operator<<(std::ostream &out, const months_type &m)
std::multimap< int, std::string, std::less< int >, std::allocator< std::pair< const int, std::string > > > months_type