Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (19 sloc) 698 Bytes
#include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
int list[] = { 1, 2, 3, 3, 2, 1, 1, 2 };
std::vector<int> v(list, list + 8);
std::cout << "Original vector:";
for (std::vector<int>::iterator i(v.begin()); i != v.end(); ++i)
std::cout << " " << *i;
std::sort(v.begin(), v.end());
std::cout << "\nSorted vector:";
for (std::vector<int>::iterator i(v.begin()); i != v.end(); ++i)
std::cout << " " << *i;
std::vector<int>::iterator low(std::lower_bound(v.begin(), v.end(), 2));
std::cout << "\nLower bound index for the first 2 element is at position: "
<< static_cast<int>(low - v.begin())
<< std::endl;
return 0;
}