c++ - How to find a lower bound in a sorted vector -
i'm pretty new c++ , not understand concepts of stl library, bear me. wrote following code snippet (pasted below) find lower_bound in sorted vector. although code works fine in release mode, asserts in debug mode (vstudio-8). believe because less_equal<int> not strictly weak ordering . from following thread: stl ordering - strict weak ordering i sort of understand weak ordering imposed stl, i'm still not clear why? in case below need use less_equal<int> since i'm trying find nearest element given value in sorted vector. is code snippet below valid? also, there better way it? insights/references weak , partial ordering helpful. int main() { vector<int> dest; for(int = 0;i <6;i++) { dest.push_back(i); } vector<int>::iterator = std::lower_bound(dest.begin(),dest.end(),4,less_equal< int >()); return 1; } the stl uses strict weak orderings because given swe (let's denote < ), can define ...