#include #include #include #include using namespace std; using namespace std::placeholders; int main() { int m[] = {1, 2, 2, 3, 5, 10}; vector v; v.assign(m, m + sizeof(m) / sizeof(m[0])); int target = 3; // 使用 std::bind 适配 std::equal_to vector::iterator ret = adjacent_find(v.begin(), v.end(), bind(equal_to(), _1, 3)); cout << *(++ret) << endl; if (ret != v.end()) { cout << "Found adjacent elements equal to " << target << "." << endl; } else { cout << "No adjacent elements equal to " << target << " found." << endl; } return 0; }