Browse Source

CPP: Extracting utility code into stl_util.h.

pull/567/head
Philip Liard 15 years ago
committed by Mihaela Rosca
parent
commit
20af731ce0
2 changed files with 13 additions and 6 deletions
  1. +3
    -6
      cpp/src/phonenumberutil.cc
  2. +10
    -0
      cpp/src/stl_util.h

+ 3
- 6
cpp/src/phonenumberutil.cc View File

@ -716,12 +716,9 @@ PhoneNumberUtil::PhoneNumberUtil()
}
PhoneNumberUtil::~PhoneNumberUtil() {
for (vector<IntRegionsPair>::const_iterator it =
country_calling_code_to_region_code_map_->begin();
it != country_calling_code_to_region_code_map_->end();
++it) {
delete it->second;
}
STLDeleteContainerPairSecondPointers(
country_calling_code_to_region_code_map_->begin(),
country_calling_code_to_region_code_map_->end());
}
// Public wrapper function to get a PhoneNumberUtil instance with the default


+ 10
- 0
cpp/src/stl_util.h View File

@ -26,6 +26,16 @@ struct OrderByFirst {
}
};
// Deletes the second attribute (pointer type expected) of the pairs contained
// in the provided range.
template <typename ForwardIterator>
void STLDeleteContainerPairSecondPointers(const ForwardIterator& begin,
const ForwardIterator& end) {
for (ForwardIterator it = begin; it != end; ++it) {
delete it->second;
}
}
} // namespace phonenumbers
} // namespace i18n


Loading…
Cancel
Save