gpt4 book ai didi

c++ - std::inserter 不工作

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:54:15 24 4
gpt4 key购买 nike

我正在编写一段代码,其中一个文件使用 set_intersection 函数,该函数的最后一个参数应该是一个插入器。但是当我编译代码时,我看到以下错误:

error C2039: 'inserter' : is not a member of 'std'
error C2873: 'inserter' : symbol cannot be used in a using-declaration
error C3861: 'inserter': identifier not found

以下是文件中使用set_intersection函数的代码

#include "Query.h"
#include "TextQuery.h"
#include <set>
#include <algorithm>
#include <iostream>

using std::set;
using std::ostream;
using std::inserter;
using std::set_intersection;

// returns intersection of its operands' result sets
set<TextQuery::line_no>
AndQuery::eval(const TextQuery& file) const
{
// virtual calls through the Query handle to get result sets for the operands
set<line_no> left = lhs.eval(file),
right = rhs.eval(file);

set<line_no> ret_lines; // destination to hold results

// writes intersection of two ranges to a destination iterator
// destination iterator in this call adds elements to ret
set_intersection(left.begin(), left.end(),
right.begin(), right.end(),
inserter(ret_lines, ret_lines.begin()));
return ret_lines;
}

最佳答案

您需要包括 <iterator>标题。

关于c++ - std::inserter 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10549116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com