Created
August 11, 2009 14:02
-
-
Save bradtgmurray/165849 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class T> | |
struct Deleter | |
{ | |
void operator()(const T* ptr) const | |
{ | |
delete ptr; | |
} | |
}; | |
std::vector<int*> numbers; | |
numbers.push_back(new int(1)); | |
numbers.push_back(new int(2)); | |
numbers.push_back(new int(3)); | |
Deleter<int> d; | |
std::for_each(numbers.begin(), numbers.end(), d); | |
numbers.clear(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment