std::min_element on list does not return the minimum

Viewed 677

I have a while loop that initialize a list with some doubles.

I would like to output the smallest value but what I have done so far seem not be working, because I don't get any output.

This is the relevant part of my code:

    list<double> allDistances;

    std::ifstream infile("ATXTFile.txt");
    while (std::getline(infile, data)) {

        //do some stuff
        //dist are some double values
        allDistances.push_back(dist);
    }

    cout << min_element(allDistances.begin(), allDistances.end()) << endl;

}
1 Answers
Related