‣ you have to provide sort with a comparison function
bool sortfunction(shared_ptr<int> x, shared_ptr<int> y) {
return *x < *y;
}
bool printfunction(shared_ptr<int> x) {
std::cout << *x << std::endl;
}
int main(int argc, char **argv) {
vector<shared_ptr<int> > vec;
vec.push_back(shared_ptr<int>(new int(9)));
vec.push_back(shared_ptr<int>(new int(5)));
vec.push_back(shared_ptr<int>(new int(7)));
std::sort(vec.begin(), vec.end(), &sortfunction);
std::for_each(vec.begin(), vec.end(), &printfunction);
return EXIT_SUCCESS;
}