私は約6種類のC++コンテナを使用しています。私は、コンテナの内容を出力するための印刷機能を書いていました。これは必要ですか?私はこれがC++ライブラリの一部だと思いますか?コンテナの印刷機能を書く必要性?
void print_list(const list<int>& list_int)
{
for (list<int>::const_iterator it = list_int.begin(); it != list_int.end(); it++) cout << *it << " ";
}
void print_um(const unordered_map<int, double>& map_int_d)
{
for(unordered_map<int, double>::const_iterator it = map_int_d.begin(); it != map_int_d.end(); ++it)cout << "[" << it->first << "," << it->second << "] ";
}
テンプレート付きのものを書く... –
http://stackoverflow.com/q/4850473/485561をご覧ください。 – Mankarse