template <class ForwardIterator, class X> ForwardIterator lower_bound( ForwardIterator xFirst, ForwardIterator xLast, const Type& kxrTarget );
#include <algorithm>
template <class ForwardIterator, class X, class BinaryPred> ForwardIterator lower_bound( ForwardIterator xFirst, ForwardIterator xLast, const Type& kxrTarget, BinaryPred xComp );
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
using namespace std;
// Create a vector instance
vector<int> qV;
// Add the first eight even entries
for (int i = 0; i < 16; i += 2) {
qV.push_back(i);
}
vector<int>::iterator qIter;
cout << "Ordered Vector: ";
for (qIter = qV.begin(); qIter != qV.end(); ++qIter) {
cout << *qIter << " ";
}
cout << endl;
// Find the least element that is less than or equal
qIter = lower_bound(qV.begin(), qV.end(), 9);
cout << "9 is the lower bound of " << *qIter << endl;
// Keep the window open
cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.