I made an iterator which when dereferenced returns a copy of std::shared_ptr that points to a dynamically allocated std::pair (created with new in the internals of the iterator). The iterator functions as is, but want to free the pair at the end of the loop to prevent memory leaks.
for (auto it = parser.begin(); it != parser.end(); ++it) {
shared_ptr<pair<string, string>> record = *it;
// Analysis of pair
// delete pair with delete, or reset
}
However, I am having trouble freeing the pair. I have tried delete record, delete *record, and record.reset(), but none of these will compile.