#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
int main() {
std::vector<int> num;
int val[5] = { 1, 2, 3, 4, 5 };
for (int i(1); i <= 5; ++i) num.push_back(i);
std::cout << *lower_bound(num.begin(), num.end(), 3) << std::endl;
std::cout << *lower_bound(val, val + 5, 3, std::less<int>()) << std::endl;
std::cout << *lower_bound(val, val + 5, 3) << std::endl;
std::cout << *lower_bound(val, val + 5, 3, [&](int x, int y) { return x < y; }) << std::endl;
return 0;
}
注意到没有 using namespace std 且前两次函数调用在 NOI Linux C++14 下可以通过编译但后两次不行。
好奇原因。