Standard C++ Library Class Reference
months.insert(value_type(31, string("October")));
months.insert(value_type(30, string("November")));
months.insert(value_type(31, string("December")));
// print out the months
cout << "All months of the year" << endl << months << endl;
// Find the Months with 30 days
pair<months_type::iterator,months_type::iterator> p =
months.equal_range(30);
// print out the 30 day months
cout << endl << "Months with 30 days" << endl;
copy(p.first,p.second,
ostream_iterator<months_type::value_type>(cout,"\n"));
return 0;
}
Output :
All months of the year
February has 28 days
April has 30 days
June has 30 days
September has 30 days
November has 30 days
January has 31 days
March has 31 days
May has 31 days
July has 31 days
August has 31 days
October has 31 days
December has 31 days
Months with 30 days
April has 30 days
June has 30 days
September has 30 days
November has 30 days
Warnings
Member function templates are used in all containers provided by the Standard Template Library. An
example of this feature is the constructor for multimap<Key,T,Compare,Allocator> that takes two
templated iterators:
template <class InputIterator>
multimap (InputIterator, InputIterator,
const Compare& = Compare(),
const Allocator& = Allocator());
multimap also has an insert function of this type. These functions, when not restricted by compiler
limitations, allow you to use any type of input iterator as arguments. For compilers that do not support
this feature we provide substitute functions that allow you to use an iterator obtained from the same