首页 > 解决方案 > 标称数据上的 C++ std::set_operations(set_difference、set_intersection 等)

问题描述

集合被分类为无序的唯一数据容器。因此,集合操作应该适用于标称数据(例如颜色)。但不知何故,像 set_difference 和 set_intersection 这样的 std::set_operations 和自定义比较函数只适用于序数数据(有序数据,如 int)。有任何想法吗?

auto comp = [](const int a, const int b) -> bool {
    return a == b; // not working
    return a != b; // not working
    return a < b;  // works as expected
}

标签: c++setstdintersectiondifference

解决方案


推荐阅读