mirror of
https://github.com/taglib/taglib.git
synced 2025-07-16 20:14:18 -04:00
Avoid unnecessary detaching of containers
If only a constant iterator is needed, make the container const if possible, otherwise use cbegin() and cend() to get a constant iterator without detaching the container. These fixes are needed so that `auto` can deduce the correct iterator type.
This commit is contained in:
@ -56,14 +56,14 @@ int main(int argc, char *argv[])
|
||||
TagLib::PropertyMap tags = f.file()->properties();
|
||||
|
||||
unsigned int longest = 0;
|
||||
for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) {
|
||||
for(TagLib::PropertyMap::ConstIterator i = tags.cbegin(); i != tags.cend(); ++i) {
|
||||
if (i->first.size() > longest) {
|
||||
longest = i->first.size();
|
||||
}
|
||||
}
|
||||
|
||||
cout << "-- TAG (properties) --" << endl;
|
||||
for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) {
|
||||
for(TagLib::PropertyMap::ConstIterator i = tags.cbegin(); i != tags.cend(); ++i) {
|
||||
for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j) {
|
||||
cout << left << std::setw(longest) << i->first << " - " << '"' << *j << '"' << endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user