In c++, is it safe to use std::numeric_limits<double>::max() as a special “flag”?
问题 Given std::vector<double> a; std::vector<int> ind; where ind is 1 sorted in ascending order. I want to do the equivalent of the following: for (auto it=ind.rbegin();it!=ind.rend();it++) a.erase(a.begin() + *it); I came up with this: for (auto it=ind.begin();it!=ind.end();it++) a[*it] = std::numeric_limits<double>::max(); std::erase(std::remove(a.begin(),a.end(),std::numeric_limits<double>::max()),a.end()); This is very fast, but it doesn't feel right to use the std::numeric_limits::max() as a