我试图greater_equal predicate
与includes() algorithm
. 我写了以下代码:
#include <iostream>
#include <algorithm>
#include <functional>
int main()
{
int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 10};
int b[] = {4, 3, 5, 1, 2, 6, 8, 9, 7, 10, 11};
unsigned int alen = sizeof(a) / sizeof(int), blen = sizeof(b) / sizeof(int);
std::sort(a, a + alen);
std::sort(b, b + blen);
if(std::includes(a, a + alen, b, b + blen, std::greater_equal<int>()))
std::cout << "a contains b" << std::endl;
}
我期待这会输出a contains b
,因为谓词greater_equal predicate
应该满足 inb
中的所有元素a
,但事实并非如此。我对它的用法有点困惑。请帮忙。